Skip to content

Commit

Permalink
added on click test-case for ImageWithCollapse.test
Browse files Browse the repository at this point in the history
  • Loading branch information
blai0264 committed May 16, 2024
1 parent a195f72 commit 34f40a2
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen } from "@testing-library/react";
import ImageWithCollapse from "./ImageWithCollapse";
import { Default } from "./ImageWithCollapse.stories.js";
import { axe, toHaveNoViolations } from "jest-axe";
import { userEvent } from "../../../node_modules/@storybook/test/dist/index";

expect.extend(toHaveNoViolations);

Expand All @@ -13,6 +14,16 @@ describe("ImageWithCollapse", () => {
expect(
screen.getByText((content) => content.startsWith("Example Title"))
).toBeInTheDocument();
const results = await axe(container);
expect(results).toHaveNoViolations();
});

test("on click renders Collapse component with default props", async () => {
const { container } = render(<ImageWithCollapse {...Default.args} />);
const collapse = screen.getByText((content) =>
content.startsWith("Example Title")
);
userEvent.click(collapse);
expect(
screen.getByText((content) => content.startsWith("Every"))
).toBeInTheDocument();
Expand Down

0 comments on commit 34f40a2

Please sign in to comment.