Skip to content

Commit

Permalink
Try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veeck committed Apr 7, 2023
1 parent 2b3cf18 commit 131a982
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions tests/unit/modules/default/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ describe("Default modules utils tests", () => {
}
});

describe("formatTime", () => {
const time = new Date();
const moment = require("moment-timezone").tz.setDefault("Europe/Berlin");

describe("formatTime", () => {
beforeAll(() => {
jest.useFakeTimers();
});
Expand All @@ -122,22 +122,17 @@ describe("Default modules utils tests", () => {
jest.setSystemTime(new Date("2023-01-01 13:13"));
});

afterEach(async () => {
jest.setSystemTime(new Date());
});

afterAll(() => {
jest.useRealTimers();
});

it("should convert correctly according to the config", () => {
time.setHours(13, 13);
expect(
formatTime(
{
timeFormat: 24
},
time
new Date()
)
).toBe("13:13");
expect(
Expand All @@ -147,7 +142,7 @@ describe("Default modules utils tests", () => {
showPeriodUpper: true,
timeFormat: 12
},
time
new Date()
)
).toBe("1:13 PM");
expect(
Expand All @@ -157,7 +152,7 @@ describe("Default modules utils tests", () => {
showPeriodUpper: false,
timeFormat: 12
},
time
new Date()
)
).toBe("1:13 pm");
expect(
Expand All @@ -166,7 +161,7 @@ describe("Default modules utils tests", () => {
showPeriod: false,
timeFormat: 12
},
time
new Date()
)
).toBe("1:13");
});
Expand All @@ -179,7 +174,7 @@ describe("Default modules utils tests", () => {
timeFormat: 24,
timezone: "America/Toronto"
},
time
new Date()
)
).toBe("07:13");
});
Expand Down

0 comments on commit 131a982

Please sign in to comment.