1 import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
2 import { ICurrencyModuleService, IStoreModuleService } from "@medusajs/types"
3 import { Modules, remoteQueryObjectFromString } from "@medusajs/utils"
4
5 jest.setTimeout(50000)
6
7 const env = {}
8
9 medusaIntegrationTestRunner({
10 env,
11 testSuite: ({ getContainer }) => {
12 describe("Link: Store Currency", () => {
13 let appContainer
14 let storeModuleService: IStoreModuleService
15 let currencyModuleService: ICurrencyModuleService
16 let remoteQuery
17
18 beforeAll(async () => {
19 appContainer = getContainer()
20 storeModuleService = appContainer.resolve(Modules.STORE)
21 currencyModuleService = appContainer.resolve(Modules.CURRENCY)
22 remoteQuery = appContainer.resolve("remoteQuery")
23 })
24
25 it("should query store and default currency with remote query", async () => {
26 const store = await storeModuleService.createStores({
27 name: "Store",
28 supported_currencies: [{ currency_code: "usd", is_default: true }],
29 })
30
31 const query = remoteQueryObjectFromString({
32 entryPoint: "store",
33 fields: [
34 "id",
35 "supported_currencies.*",
36 "supported_currencies.currency.*",
37 ],
38 })
39 const stores = await remoteQuery(query)
40
41 expect(stores).toEqual(
42 expect.arrayContaining([
43 expect.objectContaining({
44 id: store.id,
45 supported_currencies: expect.arrayContaining([
46 expect.objectContaining({
47 currency: expect.objectContaining({ code: "usd" }),
48 currency_code: "usd",
49 }),
50 ]),
51 }),
52 ])
53 )
54 })
55 })
56 },
57 })