Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -1,11 +1,14 @@
import { afterEach, describe, expect, test, vi } from "vitest";
import {
MISSING_NUMBER_PLACEHOLDER,
formatCurrency,
formatDate,
formatDateTime,
formatNumber,
formatRelativeDate,
formatRelativeTime,
toFiniteNumber,
} from "./format";
describe("locale formatters", () => {
@@ -13,6 +16,24 @@ describe("locale formatters", () => {
vi.restoreAllMocks();
});
test("renders a dash instead of NaN for values that are not finite numbers", () => {
// A Prisma Decimal that survived loader serialization as an object used to
// reach this formatter as NaN and rendered as "NaN €".
expect(formatCurrency(Number.NaN, "EUR", "de")).toBe(MISSING_NUMBER_PLACEHOLDER);
expect(formatNumber(Number.POSITIVE_INFINITY, "de")).toBe(MISSING_NUMBER_PLACEHOLDER);
expect(formatCurrency(19.99, "EUR", "de")).not.toBe(MISSING_NUMBER_PLACEHOLDER);
});
test("coerces loader payload shapes into finite numbers", () => {
expect(toFiniteNumber(19.99)).toBe(19.99);
expect(toFiniteNumber("19.99")).toBe(19.99);
expect(toFiniteNumber({ toString: () => "299.99" })).toBe(299.99);
expect(toFiniteNumber(Number.NaN)).toBeNull();
expect(toFiniteNumber(undefined)).toBeNull();
expect(toFiniteNumber("")).toBeNull();
expect(toFiniteNumber({})).toBeNull();
});
test("reuses number formatters for repeated locale and option combinations", () => {
const constructorSpy = vi.spyOn(Intl, "NumberFormat");
@@ -40,6 +61,10 @@ describe("locale formatters", () => {
expect(constructorSpy).toHaveBeenCalledTimes(1);
});
test("formats euro prices with German separators and two decimal places", () => {
expect(formatCurrency(10_000, "EUR", "de").replace(/[\u00a0\u202f]/g, " ")).toBe("10.000,00 €");
});
test("reuses date-time formatters for repeated locale and options", () => {
const constructorSpy = vi.spyOn(Intl, "DateTimeFormat");
const options: Intl.DateTimeFormatOptions = { dateStyle: "medium", timeZone: "UTC" };
@@ -50,6 +75,18 @@ describe("locale formatters", () => {
expect(constructorSpy).toHaveBeenCalledTimes(1);
});
test("formats date-times in the fixed app time zone by default", () => {
// 10:00 UTC is 11:00 in Europe/Berlin (CET) — deterministic regardless of
// the host time zone, so SSR and client output match (React #418).
expect(formatDateTime("2026-01-15T10:00:00.000Z", "de")).toBe("15.01.2026, 11:00");
// During DST (CEST) the offset is +2 hours.
expect(formatDateTime("2026-07-15T10:00:00.000Z", "de")).toBe("15.07.2026, 12:00");
});
test("keeps an explicitly passed time zone over the app default", () => {
expect(formatDateTime("2026-01-15T10:00:00.000Z", "de", { timeZone: "UTC" })).toBe("15.01.2026, 10:00");
});
test("preserves relative date output", () => {
const relativeTo = new Date("2026-05-27T10:00:00.000Z");