Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Jan 26, 2021
1 parent 0c8556f commit 11dec6e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,20 @@ describe('UrlParamsContext', () => {
search: '?rangeFrom=now-1d%2Fd&rangeTo=now-1d%2Fd&transactionId=UPDATED',
} as Location;

const nowSpy = jest.spyOn(Date, 'now').mockReturnValue(0);

const wrapper = mountParams(location);

// force an update
wrapper.setProps({ abc: 123 });
const params = getDataFromOutput(wrapper);
expect(new Date(params.start).getTime()).not.toBeNaN();
expect(new Date(params.end).getTime()).not.toBeNaN();

expect([params.start, params.end]).toEqual([
'1969-12-31T00:00:00.000Z',
'1970-01-01T00:00:00.000Z',
]);

nowSpy.mockRestore();
});

it('should refresh the time range with new values', async () => {
Expand Down

0 comments on commit 11dec6e

Please sign in to comment.