|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { CADIcon } from "../../../icons/currencies/CADIcon.js"; |
| 3 | +import { EURIcon } from "../../../icons/currencies/EURIcon.js"; |
| 4 | +import { GBPIcon } from "../../../icons/currencies/GBPIcon.js"; |
| 5 | +import { JPYIcon } from "../../../icons/currencies/JPYIcon.js"; |
| 6 | +import { USDIcon } from "../../../icons/currencies/USDIcon.js"; |
| 7 | +import { currencies, getCurrencyMeta, usdCurrency } from "./currencies.js"; |
| 8 | + |
| 9 | +describe("Currency Utilities", () => { |
| 10 | + it("should have correct number of currencies", () => { |
| 11 | + expect(currencies.length).toBe(5); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should have USD as the first currency", () => { |
| 15 | + expect(currencies[0]).toEqual(usdCurrency); |
| 16 | + }); |
| 17 | + |
| 18 | + it("should have correct properties for each currency", () => { |
| 19 | + for (const currency of currencies) { |
| 20 | + expect(currency).toHaveProperty("shorthand"); |
| 21 | + expect(currency).toHaveProperty("name"); |
| 22 | + expect(currency).toHaveProperty("icon"); |
| 23 | + } |
| 24 | + }); |
| 25 | + |
| 26 | + describe("getCurrencyMeta function", () => { |
| 27 | + it("should return correct currency meta for valid shorthand", () => { |
| 28 | + const cadMeta = getCurrencyMeta("CAD"); |
| 29 | + expect(cadMeta.shorthand).toBe("CAD"); |
| 30 | + expect(cadMeta.name).toBe("Canadian Dollar"); |
| 31 | + expect(cadMeta.icon).toBe(CADIcon); |
| 32 | + }); |
| 33 | + |
| 34 | + it("should be case-insensitive", () => { |
| 35 | + const eurMeta = getCurrencyMeta("eur"); |
| 36 | + expect(eurMeta.shorthand).toBe("EUR"); |
| 37 | + expect(eurMeta.name).toBe("Euro"); |
| 38 | + expect(eurMeta.icon).toBe(EURIcon); |
| 39 | + }); |
| 40 | + |
| 41 | + it("should return unknown currency for invalid shorthand", () => { |
| 42 | + const unknownMeta = getCurrencyMeta("XYZ"); |
| 43 | + expect(unknownMeta.shorthand).toBe("XYZ"); |
| 44 | + expect(unknownMeta.name).toBe("XYZ"); |
| 45 | + expect(unknownMeta.icon).not.toBe(USDIcon); |
| 46 | + expect(unknownMeta.icon).not.toBe(CADIcon); |
| 47 | + expect(unknownMeta.icon).not.toBe(GBPIcon); |
| 48 | + expect(unknownMeta.icon).not.toBe(EURIcon); |
| 49 | + expect(unknownMeta.icon).not.toBe(JPYIcon); |
| 50 | + }); |
| 51 | + }); |
| 52 | +}); |
0 commit comments