import { describe, expect, it } from 'vitest' import { inferRegionCode } from '../src/legacy/regions' const code = (fr: string | null, en: string | null = null) => inferRegionCode(fr, en)?.code describe('inferRegionCode', () => { it('matches FR roots, with and without accents', () => { expect(code('Vertèbres cervicales')).toBe('C') expect(code('Vertebres cervicales')).toBe('C') expect(code('Vertèbres thoraciques')).toBe('T') expect(code('Vertebres thoraciques')).toBe('T') expect(code('Vertèbres lombaires')).toBe('L') expect(code('Vertèbres sacrales')).toBe('S') expect(code('Vertèbres sacrées')).toBe('S') expect(code('Vertèbres caudales')).toBe('Cd') expect(code('Vertèbres coccygiennes')).toBe('Cd') expect(code('Région dorsale')).toBe('T') }) it('matches EN roots when the FR label is absent', () => { expect(code(null, 'Cervical Vertebrae')).toBe('C') expect(code(null, 'Thoracic Vertebrae')).toBe('T') expect(code(null, 'Lumbar Vertebrae')).toBe('L') expect(code(null, 'Sacral Vertebrae')).toBe('S') expect(code(null, 'Coccygeal Vertebrae')).toBe('Cd') }) it('returns null when no root matches', () => { expect(inferRegionCode('Épaule', 'Shoulder')).toBeNull() expect(inferRegionCode('', '')).toBeNull() expect(inferRegionCode(null, null)).toBeNull() }) it('reports the matched root and label, FR before EN', () => { expect(inferRegionCode('Vertèbres lombaires', 'Cervical')).toEqual({ code: 'L', root: 'lombair', label: 'Vertèbres lombaires', }) expect(code('Épaule', 'Cervical Vertebrae')).toBe('C') }) })