1 import type { DriveFileRevision } from '../../store';
2 import { getCategorizedRevisions } from './getCategorizedRevisions';
4 describe('getCategorizedRevisions', () => {
6 jest.useFakeTimers().setSystemTime(new Date('2023-03-17T20:00:00'));
13 it('categorizes revisions correctly', () => {
15 { createTime: 1679058000 }, // March 17, 2023 at 2:00 PM
16 { createTime: 1679036400 }, // March 17, 2023 at 7:00 AM
17 { createTime: 1678968000 }, // March 16, 2023 at 12:00 PM
18 { createTime: 1678986000 }, // March 16, 2023 at 5:00 PM
19 { createTime: 1678950000 }, // March 16, 2023 at 7:00 AM
20 { createTime: 1678777200 }, // March 14, 2023 at 7:00 AM
21 { createTime: 1678431600 }, // March 10, 2023 at 7:00 AM
22 { createTime: 1678172400 }, // March 7, 2023 at 7:00 AM
23 { createTime: 1675753200 }, // February 7, 2023 at 7:00 AM
24 { createTime: 1675234800 }, // February 1, 2023 at 7:00 AM
25 { createTime: 1640415600 }, // December 25, 2021 at 7:00 AM
26 { createTime: 1621926000 }, // May 25, 2021 at 7:00 AM
27 { createTime: 1593500400 }, // June 30, 2020 at 7:00 AM
28 { createTime: 1559372400 }, // June 1, 2019 at 7:00 AM
29 ] as DriveFileRevision[];
31 const result = getCategorizedRevisions(revisions, 'en-US');
33 expect([...result.entries()]).toStrictEqual([
34 ['today', { title: 'Today', list: [revisions[0], revisions[1]] }],
35 ['yesterday', { title: 'Yesterday', list: [revisions[2], revisions[3], revisions[4]] }],
36 ['d2', { title: 'Tuesday', list: [revisions[5]] }],
37 ['last-week', { title: 'Last week', list: [revisions[6], revisions[7]] }],
38 // eslint-disable-next-line custom-rules/deprecate-spacing-utility-classes
39 ['m1', { title: 'February', list: [revisions[8], revisions[9]] }],
40 ['2021', { title: '2021', list: [revisions[10], revisions[11]] }],
41 ['2020', { title: '2020', list: [revisions[12]] }],
42 ['2019', { title: '2019', list: [revisions[13]] }],