supplier-segmentation / src /lib /format.test.ts
brestok's picture
fix date
bf4edb5
Raw History Blame Contribute Delete
656 Bytes
import { formatDate, parseDate } from './format';
test('dates are shown day first, dot separated', () => {
expect(formatDate('2026-09-22')).toBe('22.09.2026');
expect(formatDate('2026-09-21T11:12:24.805020')).toBe('21.09.2026');
expect(formatDate(null)).toBe('—');
});
test('a typed European date is read as ISO, and only when it is a real day', () => {
expect(parseDate('22.09.2026')).toBe('2026-09-22');
expect(parseDate('4/9/2026')).toBe('2026-09-04');
expect(parseDate('04-09-2026')).toBe('2026-09-04');
expect(parseDate('31.02.2026')).toBeNull();
expect(parseDate('2026-09-22')).toBeNull();
expect(parseDate('')).toBeNull();
});