Files
medusa-store/packages/medusa-react/test/hooks/admin/notes/queries.test.ts
2023-03-03 10:09:16 +01:00

33 lines
1011 B
TypeScript

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