Implement catalog API integration and tests: commerce/src/config/markets.test.ts
davoodmehraban89 committed
Oct 13, 2026 at 23:12 UTC
5403c7473c6ef661809efb8ac0a9631a7138b693
1 file changed
+21
commerce/src/config/markets.test.ts
new
+21
@@ -0,0 +1,21 @@
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
+})