Botanique/tests/utils/time.test.ts
Mylloon 79bce239cf
Some checks failed
PR Check / lint-and-format (pull_request) Failing after 14s
comment
2024-09-27 14:49:11 +02:00

52 lines
1.2 KiB
TypeScript

import { showDate } from "../../src/utils/time";
describe("Date with correct timezone", () => {
const map = new Map([["u_time_at", "@"]]);
const date = new Date(1727434767686);
{
const name = "fr";
test(name, () => {
expect(showDate(name, map, date)).toBe("27/09/2024 @ 12:59:27");
});
}
{
const name = "en-US";
test(name, () => {
expect(showDate(name, map, date)).toBe("9/27/24, @ 1:59:27");
});
}
{
const name = "unknown";
// Depends on the system
// The important is that the date is in the correct timezone (UTC)
test(name, () => {
expect(["27/09/2024 @ 10:59:27", "9/27/24, @ 10:59:27"]).toContain(showDate(name, map, date));
});
}
{
const name = "zh-CN";
test(name, () => {
expect(showDate(name, map, date)).toBe("2024/9/27 @ 18:59:27");
});
}
});
describe("String time to seconds", () => {
{
const name = "todo";
// strToSeconds
test(name, () => {
expect(() => (name ? true : false)).toBe(true);
});
}
});
describe("Time delta", () => {
{
const name = "todo";
// timeDeltaToString
test(name, () => {
expect(() => (name ? true : false)).toBe(true);
});
}
});