feat(medusa-js,medusa-react,medusa): Add missing Currency endpoints (#2185)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
import { fixtures } from "../../../../mocks/data"
|
||||
import { useAdminUpdateCurrency } from "../../../../src/"
|
||||
import { createWrapper } from "../../../utils"
|
||||
|
||||
describe("useAdminUpdateCurrency hook", () => {
|
||||
test("updates a currency and returns it", async () => {
|
||||
const update = {
|
||||
includes_tax: true,
|
||||
}
|
||||
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminUpdateCurrency(fixtures.get("currency").code),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
result.current.mutate(update)
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data?.response.status).toEqual(200)
|
||||
expect(result.current.data?.currency).toEqual(
|
||||
expect.objectContaining({
|
||||
...fixtures.get("currency"),
|
||||
...update,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,18 @@
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
import { fixtures } from "../../../../mocks/data"
|
||||
import { useAdminCurrencies } from "../../../../src"
|
||||
import { createWrapper } from "../../../utils"
|
||||
|
||||
describe("useAdminCurrencies hook", () => {
|
||||
test("returns a list of currencies", async () => {
|
||||
const currencies = fixtures.list("currency", 1)
|
||||
const { result, waitFor } = renderHook(() => useAdminCurrencies(), {
|
||||
wrapper: createWrapper(),
|
||||
})
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.response?.status).toEqual(200)
|
||||
expect(result.current.currencies).toEqual(currencies)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user