Files
medusa-store/integration-tests/modules/__tests__/currency/admin/currency.spec.ts
Adrien de Peretti 51bb6f1e89 Chore/integration tests modules utils (#6581)
new wrapper for medusa integration tests.
for now it is only applied to the modules directory, but it could be used in the api integration tests or any other integrations that requires a db and a server up and running. 

It is not perfect, but I wanted to have something working and centralised before improving it, also avoiding too many conflicts with other prs
2024-03-06 10:03:07 +00:00

47 lines
1.2 KiB
TypeScript

import { createAdminUser } from "../../../helpers/create-admin-user"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
jest.setTimeout(50000)
const env = { MEDUSA_FF_MEDUSA_V2: true }
const adminHeaders = {
headers: { "x-medusa-access-token": "test_token" },
}
medusaIntegrationTestRunner({
env,
testSuite: ({ dbConnection, api, getContainer }) => {
describe("Currency - Admin", () => {
let container
beforeEach(async () => {
container = getContainer()
await createAdminUser(dbConnection, adminHeaders, container)
})
it("should correctly retrieve and list currencies", async () => {
const listResp = await api.get("/admin/currencies", adminHeaders)
expect(listResp.data.currencies).toEqual(
expect.arrayContaining([
expect.objectContaining({
code: "aud",
}),
expect.objectContaining({
code: "cad",
}),
])
)
const retrieveResp = await api.get(
`/admin/currencies/aud`,
adminHeaders
)
expect(retrieveResp.data.currency).toEqual(
listResp.data.currencies.find((c) => c.code === "aud")
)
})
})
},
})