-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some more tests and fix violations
- Loading branch information
1 parent
147dd53
commit 03929a1
Showing
12 changed files
with
146 additions
and
61 deletions.
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 |
---|---|---|
|
@@ -12,6 +12,8 @@ dist | |
dist-ssr | ||
*.local | ||
|
||
coverage | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
import { axe } from "jest-axe"; | ||
import { render } from "test-utils"; | ||
import { Landing } from "./pages"; | ||
|
||
describe("App", () => { | ||
it("should have no accessibility violations", async () => { | ||
const { container } = render(<Landing />); | ||
const results = await axe(container); | ||
|
||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
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,47 @@ | ||
import { axe } from "jest-axe"; | ||
import { render, screen } from "test-utils"; | ||
import Button from "./Button"; | ||
|
||
describe("Button", () => { | ||
it("should render a button", () => { | ||
render(<Button>Click me</Button>); | ||
|
||
expect(screen.getByRole("button")).toBeInTheDocument(); | ||
expect(screen.getByRole("button")).toHaveTextContent("Click me"); | ||
}); | ||
|
||
it("should have no accessibility violations", async () => { | ||
const { container } = render(<Button>Click me</Button>); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
it("can be a submit button", () => { | ||
render(<Button type="submit">Submit</Button>); | ||
expect(screen.getByRole("button")).toHaveAttribute("type", "submit"); | ||
}); | ||
|
||
it("should execute the onClick handler when clicked", async () => { | ||
const onClick = jest.fn(); | ||
const { user } = render(<Button onClick={onClick}>Click me</Button>); | ||
|
||
await user.click(screen.getByRole("button")); | ||
|
||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
|
||
it("can be disabled", async () => { | ||
const onClick = jest.fn(); | ||
const { user } = render( | ||
<Button disabled onClick={onClick}> | ||
Click me | ||
</Button>, | ||
); | ||
|
||
await user.click(screen.getByRole("button")); | ||
|
||
expect(screen.getByRole("button")).toBeDisabled(); | ||
expect(onClick).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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
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
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