Skip to content

Commit

Permalink
373-disclosure: Fix toggle and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
pcberg committed Oct 6, 2023
1 parent 4d916dd commit e0f172e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/PageContent/Disclosure/Disclosure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Disclosure = ({
<button
className="rvt-disclosure__toggle"
onClick={toggleDisclosure}
aria-expanded="false"
aria-expanded={isOpenState ? "true" : "false"}
>
{title}
</button>
Expand Down
3 changes: 3 additions & 0 deletions src/components/PageContent/Disclosure/Disclosure.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ describe("<Disclosure />", () => {
render(<Disclosure title={title}>{child}</Disclosure>);

await user.click(screen.getByRole("button", {}));
const button = screen.getByRole("button", {});
const children = screen.queryByTestId(TestUtils.Disclosure.testId, {});
expect(children).toBeVisible();
expect(children).toHaveClass("rvt-disclosure__content");
expect(button).toHaveAttribute("aria-expanded", "true");
expect(screen.queryByText(child, {})).toBeVisible();

await user.click(screen.getByRole("button", {}));
expect(button).toHaveAttribute("aria-expanded", "false");
expect(
screen.queryByTestId(TestUtils.Disclosure.testId, {})
).not.toBeInTheDocument();
Expand Down

0 comments on commit e0f172e

Please sign in to comment.