mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
- 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.
42 lines
1.3 KiB
TypeScript
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");
|
|
});
|
|
});
|