import { describe, it, expect } from "vitest"; import { formatPrice } from "@/app/api/webhooks/saleor/utils"; describe("formatPrice", () => { it("should format RSD currency correctly", () => { const result = formatPrice(5479, "RSD"); // Note: sr-RS locale uses non-breaking space between number and currency expect(result).toMatch(/5\.479,00\sRSD/); }); it("should format small amounts correctly", () => { const result = formatPrice(50, "RSD"); expect(result).toMatch(/50,00\sRSD/); }); it("should format large amounts correctly", () => { const result = formatPrice(100000, "RSD"); expect(result).toMatch(/100\.000,00\sRSD/); }); it("should format EUR currency correctly", () => { const result = formatPrice(100, "EUR"); // sr-RS locale uses € symbol for EUR expect(result).toMatch(/100,00\s€/); }); it("should format USD currency correctly", () => { const result = formatPrice(150, "USD"); // sr-RS locale uses US$ symbol for USD expect(result).toMatch(/150,00\sUS\$/); }); it("should handle decimal amounts", () => { const result = formatPrice(1000.5, "RSD"); expect(result).toMatch(/1\.000,50\sRSD/); }); it("should handle zero", () => { const result = formatPrice(0, "RSD"); expect(result).toMatch(/0,00\sRSD/); }); });