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 authored and MartinWeb committed Jan 22, 2025
1 parent 6298c43 commit 776b15a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 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,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();
});
});

0 comments on commit 776b15a

Please sign in to comment.