Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
use jest setSystemTime
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Aug 18, 2023
1 parent 54f9b52 commit 88ab4ab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/utils/DateUtils-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ describe("formatSeconds", () => {
});

describe("formatRelativeTime", () => {
let dateSpy: jest.SpyInstance<number, []>;
jest.useFakeTimers();

beforeAll(() => {
dateSpy = jest
.spyOn(global.Date, "now")
// Tuesday, 2 November 2021 11:18:03 UTC
.mockImplementation(() => 1635851883000);
// Tuesday, 2 November 2021 11:18:03 UTC
jest.setSystemTime(1635851883000);
});

afterAll(() => {
dateSpy.mockRestore();
jest.setSystemTime(jest.getRealSystemTime());
jest.useRealTimers();
});

it("returns hour format for events created in the same day", () => {
Expand Down

0 comments on commit 88ab4ab

Please sign in to comment.