38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { fireEvent, render, screen, within } from "@testing-library/react";
|
|
import { expect, it, vi } from "vitest";
|
|
import { ThinkingSelector } from "./ThinkingSelector";
|
|
|
|
it("uses selected model thinking capabilities and reconciles unavailable values", () => {
|
|
const onChange = vi.fn();
|
|
render(
|
|
<ThinkingSelector
|
|
model={{
|
|
reasoning: true,
|
|
thinkingLevelMap: {
|
|
minimal: null,
|
|
low: null,
|
|
medium: null,
|
|
high: "high",
|
|
},
|
|
}}
|
|
value="medium"
|
|
onChange={onChange}
|
|
/>,
|
|
);
|
|
|
|
const selector = screen.getByRole("combobox", { name: "Thinking" });
|
|
expect(selector).toHaveValue("off");
|
|
expect(
|
|
within(selector)
|
|
.getAllByRole("option")
|
|
.map((option) => option.textContent),
|
|
).toEqual(["Off", "High"]);
|
|
fireEvent.change(selector, { target: { value: "high" } });
|
|
expect(onChange).toHaveBeenCalledWith("high");
|
|
});
|
|
|
|
it("uses disabled native select semantics", () => {
|
|
render(<ThinkingSelector value="off" disabled onChange={vi.fn()} />);
|
|
expect(screen.getByRole("combobox", { name: "Thinking" })).toBeDisabled();
|
|
});
|