Skip to content

Commit

Permalink
add waitFor to modal.test
Browse files Browse the repository at this point in the history
  • Loading branch information
Khagou committed Mar 23, 2024
1 parent 2ffceef commit cc6c53e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/__tests__/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
render,
fireEvent,
waitForElementToBeRemoved,
waitFor
} from "@testing-library/react";
import PortfolioContent from "../src/components/Portfolio/PortfolioContent.js";
import fetchMock from "jest-fetch-mock";
Expand Down Expand Up @@ -40,15 +41,15 @@ afterEach(() => {

test("should open the modal when an image is clicked", async () => {
const { findByAltText, findByTestId } = render(<PortfolioContent />);
const image = await findByAltText("adposeAccueil");
const image = await waitFor(() => findByAltText("adposeAccueil"));
const modal = await findByTestId("portfolio");
fireEvent.click(image);
expect(modal).toBeInTheDocument();
});

test("should close the modal when the close button is clicked", async () => {
const { findByAltText, findByTestId } = render(<PortfolioContent />);
const image = await findByAltText("adposeAccueil");
const image = await waitFor(() => findByAltText("adposeAccueil"));
fireEvent.click(image);

const closeButton = await findByTestId("closeButton");
Expand Down

0 comments on commit cc6c53e

Please sign in to comment.