Skip to content
File

Blob: test/web-format.test.ts

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