Skip to content

Commit

Permalink
refactor: move from fireEvent to user
Browse files Browse the repository at this point in the history
- As per: #2815 (comment)
  • Loading branch information
Mike-Heneghan committed Feb 26, 2024
1 parent b14b788 commit 2035632
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import "@testing-library/jest-dom/extend-expect";

import { fireEvent } from "@testing-library/react";
import React from "react";
import { axe, setup } from "testUtils";

Expand All @@ -27,27 +24,27 @@ describe("FeedbackPhaseBanner presentation and functionality", () => {
expect(getByText("feedback")).toBeInTheDocument();
});

test("clicking on feedback link calls handleFeedbackClick", () => {
const { getByText } = setup(
test("clicking on feedback link calls handleFeedbackClick", async () => {
const { getByText, user } = setup(
<FeedbackPhaseBanner
handleFeedbackClick={handleFeedbackClick}
handleReportAnIssueClick={handleReportAnIssueClick}
/>,
);

fireEvent.click(getByText("feedback"));
await user.click(getByText("feedback"));
expect(handleFeedbackClick).toHaveBeenCalledTimes(1);
});

test("clicking on 'Report an issue with this page' button calls handleReportAnIssueClick", () => {
const { getByText } = setup(
test("clicking on 'Report an issue with this page' button calls handleReportAnIssueClick", async () => {
const { getByText, user } = setup(
<FeedbackPhaseBanner
handleFeedbackClick={handleFeedbackClick}
handleReportAnIssueClick={handleReportAnIssueClick}
/>,
);

fireEvent.click(getByText("Report an issue with this page"));
await user.click(getByText("Report an issue with this page"));
expect(handleReportAnIssueClick).toHaveBeenCalledTimes(1);
});
});
Expand Down

0 comments on commit 2035632

Please sign in to comment.