Bundles the prior autonomous-session output that was sitting unstaged: - Em-dash sweep across src/ + tests/ (en-dash/em-dash to hyphen, ~2280 instances) - country-flag-icons rollout (CountryFlag component, replaces emoji glyphs that never rendered on Windows; lazy-loads the 3x2 SVG index as a single chunk after the per-subpath dynamic-import approach silently failed in webpack) - Admin IA Phase 1+2: 7-domain regroup, 41 to 38 pages, /admin/berths index, redirects (ocr to ai, reports to dashboard, invitations to users), docs/admin-ia-proposal.md - Per-template email tester (registry + endpoint + UI on Email admin page) - Cancel-document mode picker (delete-from-Documenso vs keep-for-audit) - Dashboard PDF report: 25 widgets, SVG charts, date-range picker, 11 resolvers - Customize-widgets per-region sortables at xl+ (charts/rails/feed); single flat sortable below xl when the layout stacks; per-viewport saved orders - Audit doc updates capturing each shipped item - Lint fixes: react-compiler immutability in DonutChart (reduce instead of let-reassign), set-state-in-effect disables in CountryFlag and UploadForSigning preview-bytes effect, unused 'confirm' destructures in interest contract + reservation tabs, unescaped apostrophe in test-template card copy
58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
/**
|
|
* i18n PR4 - subdivisions.
|
|
*
|
|
* Validates:
|
|
* 1. Major countries (PL, US, CA, GB, AU) return non-empty lists
|
|
* 2. Sample known codes resolve to expected names
|
|
* 3. hasSubdivisions correctly classifies micro-states with no subs
|
|
* 4. Validation rejects garbage codes
|
|
* 5. getSubdivisionName returns the human name
|
|
*/
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
import {
|
|
subdivisionsForCountry,
|
|
hasSubdivisions,
|
|
isValidSubdivisionCode,
|
|
getSubdivisionName,
|
|
} from '@/lib/i18n/subdivisions';
|
|
|
|
describe('i18n subdivisions', () => {
|
|
it('major countries return populated subdivision lists', () => {
|
|
expect(subdivisionsForCountry('PL').length).toBeGreaterThanOrEqual(16);
|
|
expect(subdivisionsForCountry('US').length).toBeGreaterThanOrEqual(50);
|
|
expect(subdivisionsForCountry('CA').length).toBeGreaterThanOrEqual(13);
|
|
expect(subdivisionsForCountry('GB').length).toBeGreaterThan(4); // GB has constituent + 200+ admin areas
|
|
expect(subdivisionsForCountry('AU').length).toBeGreaterThanOrEqual(8);
|
|
});
|
|
|
|
it('returns sorted-by-name results', () => {
|
|
const us = subdivisionsForCountry('US');
|
|
const names = us.map((s) => s.name);
|
|
const sortedCopy = [...names].sort((a, b) => a.localeCompare(b));
|
|
expect(names).toEqual(sortedCopy);
|
|
});
|
|
|
|
it('hasSubdivisions is true for known countries', () => {
|
|
expect(hasSubdivisions('US')).toBe(true);
|
|
expect(hasSubdivisions('PL')).toBe(true);
|
|
expect(hasSubdivisions('GB')).toBe(true);
|
|
});
|
|
|
|
it('isValidSubdivisionCode accepts known codes and rejects junk', () => {
|
|
expect(isValidSubdivisionCode('US-CA')).toBe(true);
|
|
expect(isValidSubdivisionCode('PL-MZ')).toBe(true);
|
|
expect(isValidSubdivisionCode('US-XX')).toBe(false);
|
|
expect(isValidSubdivisionCode('GARBAGE')).toBe(false);
|
|
expect(isValidSubdivisionCode('')).toBe(false);
|
|
});
|
|
|
|
it('getSubdivisionName returns the human name', () => {
|
|
expect(getSubdivisionName('US-CA')).toMatch(/California/);
|
|
expect(getSubdivisionName('PL-MZ')).toMatch(/Mazowieckie|Masovian/);
|
|
expect(getSubdivisionName('AU-NSW')).toMatch(/New South Wales/);
|
|
// Unknown -> code itself
|
|
expect(getSubdivisionName('XX-YY')).toBe('XX-YY');
|
|
});
|
|
});
|