Some checks are pending
Build and Deploy / build (push) Waiting to run
- Fixed OrderNotificationService tests by removing React element prop assertions - Updated admin email tests to match actual function signatures - Fixed AnalyticsService test hoisting issue with vi.hoisted() - Exported AnalyticsService class for test instantiation - Converted require() to dynamic import() in singleton test - All 49 tests now passing - Coverage: 88% statements, 90% functions, 89% lines, 67% branches
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
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/);
|
|
});
|
|
});
|