Files
medusa-store/integration-tests/modules/__tests__/currency/admin/currency.spec.ts
Stevche Radevski f03a822253 feat: Add support for search to all endpoints (#7149)
* feat: Add search capability to api keys

* feat: Add support for searching to currency and customer endpoints

* fix: Clean up product search filters

* feat: Add search support to regions

* feat: Add search support to sales channels

* feat: Add search support to store module

* feat: Add search support to user module

* fix: Clean up inventory search

* feat: Add search support for payments

* fix: Add searchable attributes to stock location models

* feat: Add search support to tax

* feat: Add search support to promotions

* feat: Add search support for pricing, filtering cleanup

* fix: Further cleanups around search
2024-04-25 17:36:59 +02:00

71 lines
2.0 KiB
TypeScript

import { medusaIntegrationTestRunner } from "medusa-test-utils"
import { createAdminUser } from "../../../../helpers/create-admin-user"
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")
)
})
it("should correctly list currencies in the correct order", async () => {
const listResp = await api.get(
"/admin/currencies?order=-code",
adminHeaders
)
const first = listResp.data.currencies.shift()
expect(first).toEqual(
expect.objectContaining({ code: "zwl", name: "Zimbabwean Dollar" })
)
})
it("should allow for searching of currencies", async () => {
const listResp = await api.get(
"/admin/currencies?q=zimbabwean",
adminHeaders
)
expect(listResp.data.currencies).toHaveLength(1)
expect(listResp.data.currencies[0]).toEqual(
expect.objectContaining({ code: "zwl", name: "Zimbabwean Dollar" })
)
})
})
},
})