File
Blob: test/web-format.test.ts
| 1 | import { assert, test } from "vitest"; |
| 2 | import { formatWhen } from "@/shared/web"; |
| 3 | |
| 4 | const SAMPLE_EPOCH = 1774136183; // 2026-03-21 23:36:23 UTC |
| 5 | |
| 6 | test("formatWhen renders commit-local time for negative offsets", () => { |
| 7 | assert.strictEqual(formatWhen(SAMPLE_EPOCH, "-0700"), "2026-03-21 16:36:23 -0700"); |
| 8 | }); |
| 9 | |
| 10 | test("formatWhen renders commit-local time for positive offsets", () => { |
| 11 | assert.strictEqual(formatWhen(SAMPLE_EPOCH, "+0530"), "2026-03-22 05:06:23 +0530"); |
| 12 | }); |
| 13 | |
| 14 | test("formatWhen falls back to UTC when offset is malformed", () => { |
| 15 | assert.strictEqual(formatWhen(SAMPLE_EPOCH, "UTC"), "2026-03-21 23:36:23 UTC"); |
| 16 | }); |