64 lines · 1.6 KB · TypeScript
RawDownload
import { describe, expect, it } from "vite-plus/test"; import { ProviderInstanceId, type ProviderOptionSelection } from "@t3tools/contracts"; import type { ModelOption } from "../../lib/modelOptions";import { pendingModelAfterPress } from "./thread-settings-sheet-state"; function modelOption(  model: string,  options: ReadonlyArray<ProviderOptionSelection> = [],): ModelOption {  return {    key: `codex:${model}`,    label: model,    subtitle: "Codex",    providerKey: "codex",    providerLabel: "Codex",    providerDriver: "codex",    isDefault: false,    isLegacy: false,    capabilities: null,    selection: {      instanceId: ProviderInstanceId.make("codex"),      model,      options,    },  };} describe("thread settings sheet state", () => {  it("clears staging when the applied model is pressed", () => {    expect(      pendingModelAfterPress({        current: modelOption("gpt-next"),        pressed: modelOption("gpt-current"),        pressedIsApplied: true,      }),    ).toBeNull();  });   it("preserves staged options when the highlighted model is pressed again", () => {    const pending = modelOption("gpt-next", [{ id: "effort", value: "high" }]);     expect(      pendingModelAfterPress({        current: pending,        pressed: modelOption("gpt-next"),        pressedIsApplied: false,      }),    ).toBe(pending);  });   it("stages a different model", () => {    const pressed = modelOption("gpt-other");     expect(      pendingModelAfterPress({        current: modelOption("gpt-next"),        pressed,        pressedIsApplied: false,      }),    ).toBe(pressed);  });});