feat(BookModal): update tests
This commit is contained in:
parent
b25c54915f
commit
6548250178
2 changed files with 32 additions and 67 deletions
|
@ -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(<BookModal open={true} onClose={() => undefined} />);
|
||||
const view = render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BookModal open={true} onClose={() => undefined} />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
expect(view.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("sets book as default value", () => {
|
||||
const view = render(
|
||||
<BookModal
|
||||
open={true}
|
||||
onClose={() => undefined}
|
||||
book={{
|
||||
id: 1,
|
||||
uuid: "mockedbook",
|
||||
isbn: "123",
|
||||
title: "mockedbook",
|
||||
published: 2024,
|
||||
lastCheckoutDate: null,
|
||||
checkoutBy: null,
|
||||
shelf: "AVAILABLE",
|
||||
contact: null,
|
||||
}}
|
||||
/>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BookModal
|
||||
open={true}
|
||||
onClose={() => undefined}
|
||||
book={{
|
||||
id: 1,
|
||||
uuid: "mockedbook",
|
||||
isbn: "123",
|
||||
title: "mockedbook",
|
||||
published: 2024,
|
||||
lastCheckoutDate: null,
|
||||
checkoutBy: null,
|
||||
shelf: "AVAILABLE",
|
||||
contact: null,
|
||||
}}
|
||||
/>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
expect(view.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
@ -199,35 +199,10 @@ exports[`BookModal renders without a book 1`] = `
|
|||
<div
|
||||
class="col"
|
||||
>
|
||||
<select
|
||||
class="form-select"
|
||||
name="shelf"
|
||||
>
|
||||
<option
|
||||
value="AVAILABLE"
|
||||
>
|
||||
available
|
||||
</option>
|
||||
<option
|
||||
value="FNORD1"
|
||||
>
|
||||
fnord1
|
||||
</option>
|
||||
<option
|
||||
value="FNORD2"
|
||||
>
|
||||
fnord2
|
||||
</option>
|
||||
<option
|
||||
value="SHARING"
|
||||
>
|
||||
sharing
|
||||
</option>
|
||||
</select>
|
||||
<div
|
||||
class="invalid-feedback"
|
||||
>
|
||||
Shelf is required
|
||||
Target shelf is required
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -445,31 +420,6 @@ exports[`BookModal sets book as default value 1`] = `
|
|||
<div
|
||||
class="col"
|
||||
>
|
||||
<select
|
||||
class="form-select"
|
||||
name="shelf"
|
||||
>
|
||||
<option
|
||||
value="AVAILABLE"
|
||||
>
|
||||
available
|
||||
</option>
|
||||
<option
|
||||
value="FNORD1"
|
||||
>
|
||||
fnord1
|
||||
</option>
|
||||
<option
|
||||
value="FNORD2"
|
||||
>
|
||||
fnord2
|
||||
</option>
|
||||
<option
|
||||
value="SHARING"
|
||||
>
|
||||
sharing
|
||||
</option>
|
||||
</select>
|
||||
<div
|
||||
class="invalid-feedback"
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue