Files
magicmirrororg--magicmirror/tests/unit/modules/default/utils_spec.js
T
wehub-resource-sync dbe3ade0dc
Enforce Pull-Request Rules / check (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:19:24 +08:00

55 lines
955 B
JavaScript

global.moment = require("moment-timezone");
const defaults = require("../../../../js/defaults");
const { formatTime } = require(`../../../../${defaults.defaultModulesDir}/utils`);
describe("Default modules utils tests", () => {
describe("formatTime", () => {
const time = new Date();
beforeEach(() => {
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");
});
});
});