File size: 656 Bytes
bf4edb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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();
});