1 import { setDateLocales } from '@proton/shared/lib/i18n'
2 import { DateFormatter } from './DateFormatter'
4 describe('DateFormatter', () => {
6 setDateLocales({ dateLocale: { code: 'en-US' } })
7 jest.useFakeTimers().setSystemTime(new Date('2023-07-08'))
9 describe('formatDate', () => {
11 [new Date('2023-07-07'), 'yesterday'],
12 [new Date('2023-07-06'), 'Thursday'],
13 [new Date('2023-06-05'), 'Jun 5'],
14 ])('format %s to %s', (date, formatted) => {
15 const dateFormatter = new DateFormatter()
16 expect(dateFormatter.formatDate(date)).toBe(formatted)
20 describe('formatDate', () => {
22 [new Date('2023T04:25'), '4:25 AM'],
23 [new Date('2023T13:00'), '1:00 PM'],
24 [new Date('2023T00:00'), '12:00 AM'],
25 ])('format %s to %s', (date, formatted) => {
26 const dateFormatter = new DateFormatter()
27 expect(dateFormatter.formatTime(date)).toBe(formatted)