Files
TREK/client/src/utils/dateInputPattern.test.ts
T
Maurice cb04ebe6d2 fix(trips): the trip form drops its complaint once you edit, and the typed date hint follows your language
"Title is required" stayed on screen after the title was typed, until the
next save. Any edit in the trip form, desktop and phone, now clears the
last save's complaint; the next save checks again.

The keyboard date field always hinted DD.MM.YYYY, while it was filled and
read back in the user's own order: a Korean user saw "2026. 12. 10." under
a German hint. The hint is now the locale's own pattern (YYYY. MM. DD. in
Korean, MM/DD/YYYY in US English), and the field's name is translated.

Refs #2604
2026-10-12 15:46:02 +02:00

19 lines
794 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest';
import { dateInputPattern } from './dateInputPattern';
// The manual date field's hint has to read the way the field is filled and
// parsed in the user's language; it used to say DD.MM.YYYY everywhere (#2604).
describe('dateInputPattern', () => {
it('follows the field order and separators of the locale', () => {
expect(dateInputPattern('de-DE')).toBe('DD.MM.YYYY');
expect(dateInputPattern('en-US')).toBe('MM/DD/YYYY');
expect(dateInputPattern('en-GB')).toBe('DD/MM/YYYY');
expect(dateInputPattern('ko-KR')).toBe('YYYY. MM. DD.');
});
it('takes the shape only, never the locale digits', () => {
expect(dateInputPattern('ar')).not.toMatch(/[٠-٩\d]/);
expect(dateInputPattern('ar')).toContain('YYYY');
});
});