Skip to content

Commit 6507d67

Browse files
committed
test: Fix fail with data parsing test
1 parent 092410a commit 6507d67

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/cubejs-api-gateway/test/dateParser.test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ describe('dateParser', () => {
7373
});
7474

7575
test('from 1 quarter ago to now', () => {
76-
Date.now = jest.fn().mockReturnValue(new Date(2021, 4, 3, 12, 0, 0, 0));
76+
const now = new Date(2021, 4, 3, 12, 0, 0, 0);
77+
Date.now = jest.fn().mockReturnValue(now);
7778

78-
expect(dateParser('from 1 quarter ago to now', 'UTC')).toStrictEqual(
79-
['2023-01-03T00:00:00.000', '2023-04-03T23:59:59.999']
79+
expect(dateParser('from 1 quarter ago to now', 'UTC', now)).toStrictEqual(
80+
['2021-02-03T00:00:00.000', '2021-05-03T23:59:59.999']
8081
);
8182

8283
Date.now.mockRestore();
@@ -101,9 +102,10 @@ describe('dateParser', () => {
101102
});
102103

103104
test('last 2 quarters', () => {
104-
Date.now = jest.fn().mockReturnValue(new Date(2021, 1, 15, 13, 0, 0, 0));
105+
const now = new Date(2021, 1, 15, 13, 0, 0, 0);
106+
Date.now = jest.fn().mockReturnValue(now);
105107

106-
expect(dateParser('last 2 quarters', 'UTC', new Date(2021, 1, 15, 13, 0, 0, 0))).toStrictEqual([
108+
expect(dateParser('last 2 quarters', 'UTC', now)).toStrictEqual([
107109
'2020-07-01T00:00:00.000',
108110
'2020-12-31T23:59:59.999',
109111
]);

0 commit comments

Comments
 (0)