1
2 import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
3 import {
4 adminHeaders,
5 createAdminUser,
6 } from "../../../../helpers/create-admin-user"
7
8 jest.setTimeout(30000)
9
10 medusaIntegrationTestRunner({
11 env: {},
12 testSuite: ({ dbConnection, getContainer, api, dbUtils }) => {
13 beforeAll(async () => {
14 const container = getContainer()
15 await createAdminUser(dbConnection, adminHeaders, container)
16
17 await dbUtils.snapshot()
18 })
19
20 describe("GET /admin/currencies", () => {
21 it("should retrieve the currencies", async () => {
22 const response = await api.get(
23 "/admin/currencies?order=code",
24 adminHeaders
25 )
26
27 expect(response.status).toEqual(200)
28 expect(response.data.currencies).toHaveLength(126)
29 expect(response.data.currencies).toEqual(
30 expect.arrayContaining([
31 expect.objectContaining({
32 code: "gmd",
33 name: "Gambian Dalasi",
34 }),
35 expect.objectContaining({
36 code: "usd",
37 name: "US Dollar",
38 }),
39 ])
40 )
41 })
42
43 it("should retrieve the currencies filtered with q param", async () => {
44 const response = await api.get(
45 `/admin/currencies?q=us&order=code`,
46 adminHeaders
47 )
48
49 expect(response.status).toEqual(200)
50 expect(response.data.currencies).toEqual(
51 expect.arrayContaining([
52 expect.objectContaining({
53 code: "aud",
54 name: "Australian Dollar",
55 }),
56 expect.objectContaining({
57 code: "byn",
58 name: "Belarusian Ruble",
59 }),
60 expect.objectContaining({
61 code: "rub",
62 name: "Russian Ruble",
63 }),
64 expect.objectContaining({
65 code: "usd",
66 name: "US Dollar",
67 }),
68 ])
69 )
70 })
71 })
72 },
73
74 // BREAKING: There was an "should update currency includes_tax" test that no longer applies in v2 (realted to MEDUSA_FF_TAX_INCLUSIVE_PRICING)
75 })