From 65482501787576b003e5ee91e3c7863449210538 Mon Sep 17 00:00:00 2001 From: 0ry5 Date: Fri, 17 Jan 2025 15:14:56 +0100 Subject: [PATCH] feat(BookModal): update tests --- .../modals/__tests__/BookModal.test.tsx | 47 +++++++++++------ .../__snapshots__/BookModal.test.tsx.snap | 52 +------------------ 2 files changed, 32 insertions(+), 67 deletions(-) diff --git a/frontend/src/shared/components/modals/__tests__/BookModal.test.tsx b/frontend/src/shared/components/modals/__tests__/BookModal.test.tsx index 84b271d..b6d8c2c 100644 --- a/frontend/src/shared/components/modals/__tests__/BookModal.test.tsx +++ b/frontend/src/shared/components/modals/__tests__/BookModal.test.tsx @@ -1,29 +1,44 @@ import { render } from "@testing-library/react"; import { BookModal } from "../BookModal"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; describe("BookModal", () => { + global.fetch = jest.fn(() => + Promise.resolve({ + json: () => Promise.resolve({ test: 100 }), + }) + ) as jest.Mock; + + const queryClient = new QueryClient(); + it("renders without a book", () => { - const view = render( undefined} />); + const view = render( + + undefined} /> + + ); expect(view.baseElement).toMatchSnapshot(); }); it("sets book as default value", () => { const view = render( - undefined} - book={{ - id: 1, - uuid: "mockedbook", - isbn: "123", - title: "mockedbook", - published: 2024, - lastCheckoutDate: null, - checkoutBy: null, - shelf: "AVAILABLE", - contact: null, - }} - /> + + undefined} + book={{ + id: 1, + uuid: "mockedbook", + isbn: "123", + title: "mockedbook", + published: 2024, + lastCheckoutDate: null, + checkoutBy: null, + shelf: "AVAILABLE", + contact: null, + }} + /> + ); expect(view.baseElement).toMatchSnapshot(); }); diff --git a/frontend/src/shared/components/modals/__tests__/__snapshots__/BookModal.test.tsx.snap b/frontend/src/shared/components/modals/__tests__/__snapshots__/BookModal.test.tsx.snap index 8049ff5..a3862dd 100644 --- a/frontend/src/shared/components/modals/__tests__/__snapshots__/BookModal.test.tsx.snap +++ b/frontend/src/shared/components/modals/__tests__/__snapshots__/BookModal.test.tsx.snap @@ -199,35 +199,10 @@ exports[`BookModal renders without a book 1`] = `
-
- Shelf is required + Target shelf is required
@@ -445,31 +420,6 @@ exports[`BookModal sets book as default value 1`] = `
-