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>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user