import { describe, expect, it } from "vitest"; import { formatAmount, formatResetLabel } from "./format"; describe("formatAmount", () => { it("groups thousands in the app's language", () => { expect(formatAmount(12345, "credits", "en")).toBe("12,345"); expect(formatAmount(12345, "requests", "en")).toBe("12,345"); expect(formatAmount(12345, "credits", "fr").replace(/\s/g, " ")).toBe("12 345"); }); it("formats dollars as the language writes currency", () => { expect(formatAmount(1234.5, "usd", "en")).toBe("$1,234.50"); expect(formatAmount(1234.5, "usd", "fr").replace(/\s/g, " ")).toBe("1 234,50 $US"); }); }); it("retained reset times that have passed do not claim the quota is resetting", () => { const past = "2000-01-01T00:00:00.000Z"; expect(formatResetLabel(past, true)).toBe("Reset time passed"); expect(formatResetLabel(past)).toBe("resetting now"); expect(formatResetLabel(null, true)).toBeNull(); });