import { describe, expect, it } from "vitest"; import "@edr/ui-common/display-timezone"; // The pin must hold on ANY machine timezone — these assertions are the bug: // before the patch they only passed on a PC already set to UTC+3. describe("display-timezone pin (EAT, UTC+3)", () => { const utcMidnight = new Date("2026-01-01T00:00:00Z"); it("formats Date.toLocale* in EAT regardless of machine timezone", () => { expect(utcMidnight.toLocaleTimeString("en-GB", { hour12: false })).toBe( "03:00:00", ); // 22:00 UTC is already the NEXT day in EAT. expect(new Date("2026-01-01T22:00:00Z").toLocaleDateString("en-CA")).toBe( "2026-01-02", ); }); it("formats Intl.DateTimeFormat in EAT and keeps instanceof/statics", () => { const fmt = new Intl.DateTimeFormat("en-GB", { hour: "2-digit", minute: "2-digit", hour12: false, }); expect(fmt.format(utcMidnight)).toBe("03:00"); expect(fmt).toBeInstanceOf(Intl.DateTimeFormat); expect(Intl.DateTimeFormat.supportedLocalesOf(["en-GB"])).toContain( "en-GB", ); }); it("respects an explicit timeZone option", () => { expect( utcMidnight.toLocaleTimeString("en-GB", { hour12: false, timeZone: "UTC", }), ).toBe("00:00:00"); }); });