fix: close final widget review gaps
This commit is contained in:
1 parent
c67c893f8f
commit
2efa6bcd4c
4 files changed
+108
-54
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import dayjs from "dayjs";
|
||||
import frenchLocale from "dayjs/locale/fr";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { formatRelativeTime, getResourceTimestamp } from "./coolify-utils";
|
||||
|
||||
describe("Coolify time formatting", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-08-02T12:00:00Z"));
|
||||
dayjs.locale(frenchLocale);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
dayjs.locale("en");
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("uses the active Day.js locale for past and future timestamps", () => {
|
||||
expect(formatRelativeTime("2026-08-02T11:00:00Z")).toBe("il y a une heure");
|
||||
expect(formatRelativeTime("2026-08-02T13:00:00Z")).toBe("dans une heure");
|
||||
});
|
||||
|
||||
it("omits missing, invalid, and currently running timestamps", () => {
|
||||
expect(formatRelativeTime(undefined)).toBeUndefined();
|
||||
expect(formatRelativeTime("invalid")).toBeUndefined();
|
||||
expect(getResourceTimestamp({ status: "running", updated_at: "2026-08-02T11:00:00Z" }, "service")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user