import { describe, expect, it } from "vitest"; import { formatAuditTimestamp } from "@/domain/work-orders/utils/format-audit-timestamp"; describe("formatAuditTimestamp (SH-361)", () => { it("includes the calendar date and the time for an ISO audit time", () => { const iso = "2026-09-15T19:42:00"; const date = new Date(iso); const expectedDate = date.toLocaleDateString("en-US", { month: "2-digit", day: "2-digit", year: "numeric", }); const formatted = formatAuditTimestamp(iso); expect(formatted).toBe(`${expectedDate} · 7:42 PM`); expect(formatted).toMatch(/^\d{2}\/\d{2}\/\d{4} · \d{1,2}:\d{2} (AM|PM)$/); }); it("distinguishes the same time of day on different dates", () => { expect(formatAuditTimestamp("2026-09-14T09:48:00")).not.toBe( formatAuditTimestamp("2026-09-15T09:48:00"), ); }); it("keeps pre-formatted or unparseable strings unchanged", () => { expect(formatAuditTimestamp("· 7:42 PM")).toBe("· 7:42 PM"); expect(formatAuditTimestamp("09/15/2026 · 7:42 PM")).toBe("09/15/2026 · 7:42 PM"); }); it("returns an empty string when there is no time", () => { expect(formatAuditTimestamp("")).toBe(""); }); });