import "@testing-library/jest-dom"; import { fireEvent, render } from "@testing-library/react"; import Select from "./Select"; describe("Select", () => { const options = [ { value: "option1", label: "Option 1" }, { value: "option2", label: "Option 2" }, ]; test("renders without crashing", () => { const { getByRole } = render(); const select = getByRole("combobox") as HTMLSelectElement; expect(select.children.length).toBe(2); expect((select.children[0] as HTMLOptionElement).value).toBe("option1"); expect((select.children[1] as HTMLOptionElement).value).toBe("option2"); }); test("calls onChange when an option is selected", () => { const handleChange = vi.fn(); const { getByRole } = render( , ); const select = getByRole("combobox") as HTMLSelectElement; expect(select.value).toBe("option2"); }); });