Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

thread-settings-sheet-state.test.ts

64 lines1.6 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { ProviderInstanceId, type ProviderOptionSelection } from "@t3tools/contracts";
4​
5import type { ModelOption } from "../../lib/modelOptions";
6import { pendingModelAfterPress } from "./thread-settings-sheet-state";
7​
8function modelOption(
9 model: string,
10 options: ReadonlyArray<ProviderOptionSelection> = [],
11): ModelOption {
12 return {
13 key: `codex:${model}`,
14 label: model,
15 subtitle: "Codex",
16 providerKey: "codex",
17 providerLabel: "Codex",
18 providerDriver: "codex",
19 isDefault: false,
20 isLegacy: false,
21 capabilities: null,
22 selection: {
23 instanceId: ProviderInstanceId.make("codex"),
24 model,
25 options,
26 },
27 };
29​
30describe("thread settings sheet state", () => {
31 it("clears staging when the applied model is pressed", () => {
32 expect(
33 pendingModelAfterPress({
34 current: modelOption("gpt-next"),
35 pressed: modelOption("gpt-current"),
36 pressedIsApplied: true,
37 }),
38 ).toBeNull();
39 });
40​
41 it("preserves staged options when the highlighted model is pressed again", () => {
42 const pending = modelOption("gpt-next", [{ id: "effort", value: "high" }]);
43​
44 expect(
45 pendingModelAfterPress({
46 current: pending,
47 pressed: modelOption("gpt-next"),
48 pressedIsApplied: false,
49 }),
50 ).toBe(pending);
51 });
52​
53 it("stages a different model", () => {
54 const pressed = modelOption("gpt-other");
55​
56 expect(
57 pendingModelAfterPress({
58 current: modelOption("gpt-next"),
59 pressed,
60 pressedIsApplied: false,
61 }),
62 ).toBe(pressed);
63 });
64});