import { describe, expect, it } from "vitest"; import { formatValue, gridColumns } from "./format"; describe("formatting and layout", () => { it("formats numbers deterministically and leaves strings alone", () => { expect(formatValue({ value: 42279 })).toBe("42,279"); expect(formatValue({ value: 42279, locale: "de-DE" })).toBe("42.279"); expect( formatValue({ value: 0.875, formatOptions: { style: "percent", maximumFractionDigits: 1 } }), ).toBe("87.5%"); expect(formatValue({ value: "0042 Pop" })).toBe("0042 Pop"); expect(formatValue({ value: 0 })).toBe("0"); }); it("uses available-width columns and validates explicit counts", () => { expect(gridColumns()).toContain("auto-fit"); expect(gridColumns(2)).toBe("repeat(2, minmax(0, 1fr))"); for (const value of [0, -1, 1.5, NaN, Infinity]) { expect(() => gridColumns(value)).toThrow(RangeError); } }); });