-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added tests for progress (#31)
* test: jest testing setup * test: fixed jest typescript definitions * fix: test script * chore(deps): move deps to dev * test: added tests for accordion * test: added husky precommit test * test: axe container test * chore(infra): added github action test * test: added tests for number input * fix: a11y aria-valuetext issue with NumberInput * test: added tests for Slider * test: added tests for progress
- Loading branch information
1 parent
88175da
commit 02415bf
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as React from "react"; | ||
import { axe } from "jest-axe"; | ||
import { render } from "reakit-test-utils"; | ||
|
||
import { Progress, ProgressProps, useProgressState } from ".."; | ||
|
||
const ProgressComp = (props: Partial<ProgressProps>) => { | ||
const progress = useProgressState(props); | ||
|
||
return ( | ||
<div> | ||
<Progress data-testid="progress" {...progress} /> | ||
</div> | ||
); | ||
}; | ||
|
||
describe("Progress", () => { | ||
it("should render correctly", () => { | ||
const { baseElement } = render(<ProgressComp value={10} />); | ||
|
||
expect(baseElement).toMatchInlineSnapshot(` | ||
<body> | ||
<div> | ||
<div> | ||
<div | ||
aria-valuemax="100" | ||
aria-valuemin="0" | ||
aria-valuenow="10" | ||
aria-valuetext="10" | ||
data-testid="progress" | ||
role="progressbar" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`); | ||
}); | ||
|
||
it("should render isIndeterminate", () => { | ||
const { getByTestId: testid } = render(<ProgressComp />); | ||
|
||
expect(testid("progress")).toHaveAttribute("data-indeterminate", ""); | ||
}); | ||
|
||
test("Progress renders with no a11y violations", async () => { | ||
const { container } = render(<ProgressComp value={50} />); | ||
const results = await axe(container); | ||
|
||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |