Skip to content

Commit

Permalink
test(SelectInput): add test for SelectInput component
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakan Orak committed Jan 14, 2025
1 parent 7093e34 commit 0c61fc8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions slash/react/src/Form/Select/__tests__/SelectInput.test.tsx
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();
});
});

0 comments on commit 0c61fc8

Please sign in to comment.