Skip to content

Commit

Permalink
fix checkbox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chance Strickland committed Mar 10, 2020
1 parent 2b06a9a commit 4b37387
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/checkbox/__tests__/checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { render, fireEvent, act } from "$test/utils";
describe("<MixedCheckbox />", () => {
it("should not have basic a11y issues", async () => {
let { container, getByTestId } = render(<BasicMixedCheckbox />);
let results = await axe(container);
expect(results).toHaveNoViolations();

act(() => void fireEvent.click(getByTestId("checkbox")));
let newResults = await axe(container);
expect(newResults).toHaveNoViolations();
await act(async () => {
expect(await axe(container)).toHaveNoViolations();

fireEvent.click(getByTestId("checkbox"));
expect(await axe(container)).toHaveNoViolations();
});
});

// TODO: Write tests for mixed checkbox
Expand All @@ -25,14 +26,16 @@ describe("<MixedCheckbox />", () => {
describe("<CustomCheckbox />", () => {
it("should not have basic a11y issues", async () => {
let { container, getByTestId } = render(<BasicCustomCheckbox />);
let results = await axe(container);
expect(results).toHaveNoViolations();

act(() => void fireEvent.click(getByTestId("checkbox-1")));
expect(await axe(container)).toHaveNoViolations();
await act(async () => {
expect(await axe(container)).toHaveNoViolations();

fireEvent.click(getByTestId("checkbox-1"));
expect(await axe(container)).toHaveNoViolations();

act(() => void fireEvent.click(getByTestId("checkbox-2")));
expect(await axe(container)).toHaveNoViolations();
fireEvent.click(getByTestId("checkbox-2"));
expect(await axe(container)).toHaveNoViolations();
});
});

// TODO: Write tests for custom checkbox
Expand Down

0 comments on commit 4b37387

Please sign in to comment.