|
1
|
import { describe, expect, it } from "vitest" |
|
2
|
import { isMarketCode, isStoreLocale, LOCALES, MARKETS, rialToToman } from "./markets" |
|
3
|
|
|
4
|
describe("market configuration", () => { |
|
5
|
it("contains five configured markets", () => expect(Object.keys(MARKETS)).toEqual(["IR", "AE", "OM", "IQ", "QA"])) |
|
6
|
it("supports Persian and Arabic RTL plus English LTR", () => { |
|
7
|
expect(LOCALES["fa-IR"].direction).toBe("rtl") |
|
8
|
expect(LOCALES.ar.direction).toBe("rtl") |
|
9
|
expect(LOCALES.en.direction).toBe("ltr") |
|
10
|
}) |
|
11
|
it("validates codes", () => { |
|
12
|
expect(isMarketCode("IR")).toBe(true) |
|
13
|
expect(isMarketCode("US")).toBe(false) |
|
14
|
expect(isStoreLocale("ar")).toBe(true) |
|
15
|
expect(isStoreLocale("fr")).toBe(false) |
|
16
|
}) |
|
17
|
it("converts rials to tomans without FX", () => { |
|
18
|
expect(rialToToman(1250)).toBe(125) |
|
19
|
expect(() => rialToToman(Infinity)).toThrow() |
|
20
|
}) |
|
21
|
}) |