Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.0 kB ยท 57 lines
TypeScript
at incident-api
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import { defaultStatusBlocksLabels as labels } from "@openstatus/ui/components/blocks/status.utils";import { expect } from "@std/expect";import { describe, test } from "@std/testing/bdd";
// Status-page timestamps render in UTC, so the user-facing labels carry a// trailing "(UTC)" to tell viewers which zone they are reading (see #2302).describe("defaultStatusBlocksLabels UTC suffix", () => { const date = new Date("2024-01-15T14:30:00Z");
test("formatDate appends the UTC suffix", () => { expect(labels.formatDate(date)).toBe("January 15, 2024 (UTC)"); });
test("formatDateShort omits the UTC suffix (date-only label)", () => { expect(labels.formatDateShort(date)).toBe("Jan 15, 2024"); });
test("formatDateTime appends the UTC suffix", () => { expect(labels.formatDateTime(date)).toBe("January 15 at 2:30 PM (UTC)"); });
describe("formatDateRange", () => { test("appends a single UTC suffix to the whole range", () => { expect( labels.formatDateRange( new Date("2024-01-15T10:00:00Z"), new Date("2024-01-15T15:00:00Z"), ), ).toBe("January 15 at 10:00 AM - 3:00 PM (UTC)"); });
test("appends the UTC suffix to an open-ended range", () => { expect( labels.formatDateRange(new Date("2024-01-15T10:00:00Z"), undefined), ).toBe("Since January 15 at 10:00 AM (UTC)"); });
test("appends the UTC suffix to an open-start range", () => { expect( labels.formatDateRange(undefined, new Date("2024-01-15T15:00:00Z")), ).toBe("Until January 15 at 3:00 PM (UTC)"); });
test("leaves `All time` without a UTC suffix", () => { expect(labels.formatDateRange()).toBe("All time"); }); });
test("formatDateRangeParts marks only the trailing `to` part", () => { expect( labels.formatDateRangeParts( new Date("2024-01-15T10:00:00Z"), new Date("2024-01-15T15:00:00Z"), ), ).toEqual({ from: "January 15 at 10:00 AM", to: "3:00 PM (UTC)" }); });});