-
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
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
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,44 @@ | ||
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", () => { | ||
// Act | ||
render( | ||
<SelectInput | ||
label="label select input" | ||
mode="default" | ||
options={options} | ||
/>, | ||
); | ||
|
||
// Assert | ||
const labelSelectInput = screen.getByRole("combobox", { | ||
name: "label select input", | ||
}); | ||
expect(labelSelectInput).toHaveClass("af-form__input-select"); | ||
}); | ||
|
||
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(); | ||
}); | ||
}); |