import { toLatinDigits } from './digits';

/**
 * Exercised by the voice pipeline on two untrusted inputs: spoken dates, and the tooth
 * code the extraction model echoes back — a Persian-digit "۲۶" that fails to normalise
 * costs the clinician a tooth, silently.
 */
describe('toLatinDigits', () => {
  it('normalises Persian digits and leaves everything else alone', () => {
    expect(
      toLatinDigits('\u06F1\u06F4\u06F0\u06F4/\u06F0\u06F7/\u06F2\u06F5'),
    ).toBe('1404/07/25');
    expect(toLatinDigits('1404/07/25')).toBe('1404/07/25');
    expect(toLatinDigits('\u062F\u0646\u062F\u0627\u0646 \u06F1\u06F4')).toBe(
      '\u062F\u0646\u062F\u0627\u0646 14',
    );
  });

  it('also normalises the Arabic-Indic block, which ASR output can carry', () => {
    // U+0660..U+0669, distinct code points from the Persian U+06F0..U+06F9 block.
    expect(
      toLatinDigits('\u0661\u0664\u0660\u0664/\u0660\u0667/\u0662\u0665'),
    ).toBe('1404/07/25');
  });

  it('normalises a transcript that mixes both blocks with ASCII', () => {
    expect(toLatinDigits('\u06F1\u06F4 and \u0661\u0665 and 16')).toBe(
      '14 and 15 and 16',
    );
  });
});
