2023-07-01 21:17:31 +02:00
|
|
|
global.moment = require("moment-timezone");
|
2026-01-27 08:37:52 +01:00
|
|
|
const defaults = require("../../../../js/defaults");
|
|
|
|
|
|
2026-02-23 10:27:29 +01:00
|
|
|
const { formatTime } = require(`../../../../${defaults.defaultModulesDir}/utils`);
|
2023-04-04 20:44:32 +02:00
|
|
|
|
2023-07-01 21:17:31 +02:00
|
|
|
describe("Default modules utils tests", () => {
|
|
|
|
|
describe("formatTime", () => {
|
|
|
|
|
const time = new Date();
|
|
|
|
|
|
2026-02-25 10:55:56 +01:00
|
|
|
beforeEach(() => {
|
2023-07-01 21:17:31 +02:00
|
|
|
time.setHours(13, 13);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should convert correctly according to the config", () => {
|
|
|
|
|
expect(
|
|
|
|
|
formatTime(
|
|
|
|
|
{
|
|
|
|
|
timeFormat: 24
|
|
|
|
|
},
|
|
|
|
|
time
|
|
|
|
|
)
|
|
|
|
|
).toBe("13:13");
|
|
|
|
|
expect(
|
|
|
|
|
formatTime(
|
|
|
|
|
{
|
|
|
|
|
showPeriod: true,
|
|
|
|
|
showPeriodUpper: true,
|
|
|
|
|
timeFormat: 12
|
|
|
|
|
},
|
|
|
|
|
time
|
|
|
|
|
)
|
|
|
|
|
).toBe("1:13 PM");
|
|
|
|
|
expect(
|
|
|
|
|
formatTime(
|
|
|
|
|
{
|
|
|
|
|
showPeriod: true,
|
|
|
|
|
showPeriodUpper: false,
|
|
|
|
|
timeFormat: 12
|
|
|
|
|
},
|
|
|
|
|
time
|
|
|
|
|
)
|
|
|
|
|
).toBe("1:13 pm");
|
|
|
|
|
expect(
|
|
|
|
|
formatTime(
|
|
|
|
|
{
|
|
|
|
|
showPeriod: false,
|
|
|
|
|
timeFormat: 12
|
|
|
|
|
},
|
|
|
|
|
time
|
|
|
|
|
)
|
|
|
|
|
).toBe("1:13");
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-01-01 18:09:08 +01:00
|
|
|
});
|