-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(SelectInput): add test for SelectInput component
- Loading branch information
Hakan Orak
committed
Jan 14, 2025
1 parent
7093e34
commit 0c61fc8
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
slash/react/src/Form/Select/__tests__/SelectInput.test.tsx
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,42 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { axe } from "jest-axe"; | ||
import { SelectInput } from "../SelectInput"; | ||
|
||
const options = [ | ||
{ value: "fun", label: "For fun" }, | ||
{ value: "work", label: "For work" }, | ||
{ value: "drink", label: "For drink" }, | ||
]; | ||
|
||
describe("SelectInput", () => { | ||
it("should have label", async () => { | ||
// Act | ||
render( | ||
<SelectInput | ||
label="label select input" | ||
mode="default" | ||
options={options} | ||
/>, | ||
); | ||
|
||
// Assert | ||
const labelSelectInput = screen.getByText("label select input"); | ||
expect(labelSelectInput).toHaveClass("af-form__group-label"); | ||
}); | ||
|
||
it("shouldn't have an accessibility violation <Select />", async () => { | ||
// Act | ||
const { container } = render( | ||
<SelectInput | ||
label="label select input" | ||
aria-label="select-default" | ||
onChange={() => console.log("Some change")} | ||
defaultValue="fun" | ||
options={options} | ||
/>, | ||
); | ||
|
||
// Assert | ||
expect(await axe(container)).toHaveNoViolations(); | ||
}); | ||
}); |