Files
edr-platform/apps/edr-freight-web/backoffice/src/lib/display-timezone.test.ts
Marshal 0d8c63328a add items per wagon map to cargo types and sync bulk rate units
- Implemented  in the  to manage the physical item capacity for each wagon type.
- Added a new migration to create the  column in the  table.
- Introduced  method in  to update rate units when cargo type unit of measure changes.
- Updated booking calculations to consider items per wagon for break-bulk cargo.
- Refactored various components to utilize the new items fit logic and ensure consistent date formatting across the application.
- Added tests for the new display timezone functionality to ensure consistent date/time representation across different user settings.
2026-08-01 09:55:21 +00:00

42 lines
1.3 KiB
TypeScript

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");
});
});