mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
1 commit
89dd55210d
...
f8ee575b85
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8ee575b85 |
2 changed files with 1 additions and 46 deletions
|
|
@ -1,44 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
|
||||||
import ImageGalleryModal from "../../../components/ImageGallery/ImageGalleryModal/ImageGalleryModal";
|
|
||||||
import "@testing-library/jest-dom";
|
|
||||||
|
|
||||||
jest.mock("../../../components/ImageGallery/ImageGallery", () => ({
|
|
||||||
__esModule: true,
|
|
||||||
default: jest.fn(() => <div data-testid="image-gallery" />),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe("ImageGalleryModal", () => {
|
|
||||||
|
|
||||||
it("renders button correctly", () => {
|
|
||||||
render(<ImageGalleryModal />);
|
|
||||||
|
|
||||||
const button = screen.getByLabelText(/images-open/i);
|
|
||||||
expect(button).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("opens the modal when button is clicked", () => {
|
|
||||||
render(<ImageGalleryModal />);
|
|
||||||
|
|
||||||
const button = screen.getByRole("button", { name: /images/i });
|
|
||||||
fireEvent.click(button);
|
|
||||||
|
|
||||||
const dialog = screen.getByRole("dialog");
|
|
||||||
expect(dialog).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it("closes the modal when close button is clicked", async () => {
|
|
||||||
render(<ImageGalleryModal />);
|
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /images/i }));
|
|
||||||
|
|
||||||
const closeButton = screen.getByRole("button", { name: /close/i });
|
|
||||||
fireEvent.click(closeButton);
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -25,7 +25,7 @@ const ImageGalleryModal: React.FC<ImageGalleryModalProps> = ({ handleCopy }) =>
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
aria-label='images-open'
|
aria-label='Téléverser'
|
||||||
onClick={() => handleOpen()}>
|
onClick={() => handleOpen()}>
|
||||||
Images <ImageSearch />
|
Images <ImageSearch />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -34,7 +34,6 @@ const ImageGalleryModal: React.FC<ImageGalleryModalProps> = ({ handleCopy }) =>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label="close"
|
|
||||||
sx={{
|
sx={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
right: 8,
|
right: 8,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue