Files
medusa-store/packages/medusa-react/test/hooks/admin/customer-groups/queries.test.ts
Frane Polić daf49bcaf3 feat: customer groups react hooks (#1153)
* fix: msw handlers for medusa-react storybook

* feat: add customer groups query hooks

* feat: add create/update customer groups hooks

* feat: add customer group batch  hooks

* feat: add test files, fix import

* add customer groups fixture

* add customer gorup mock endpoints

* add test cases

* add hook comments

* fix: typos

* fix: comments refactor

* fix: comment

Co-authored-by: fPolic <frane@medusajs.com>
2022-03-07 12:52:48 +01:00

35 lines
1.1 KiB
TypeScript

import { renderHook } from "@testing-library/react-hooks"
import { useAdminCustomerGroup, useAdminCustomerGroups } from "../../../../src"
import { fixtures } from "../../../../mocks/data"
import { createWrapper } from "../../../utils"
describe("useAdminCustomerGroup hook", () => {
test("returns a customer group", async () => {
const group = fixtures.get("customer_group")
const { result, waitFor } = renderHook(
() => useAdminCustomerGroup(group.id),
{
wrapper: createWrapper(),
}
)
await waitFor(() => result.current.isSuccess)
expect(result.current.response.status).toEqual(200)
expect(result.current.customer_group).toEqual(group)
})
test("returns a list of customer groups", async () => {
const groups = fixtures.list("customer_group")
const { result, waitFor } = renderHook(() => useAdminCustomerGroups(), {
wrapper: createWrapper(),
})
await waitFor(() => result.current.isSuccess)
expect(result.current.response.status).toEqual(200)
expect(result.current.customer_groups).toEqual(groups)
})
})