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

sdkModel.test.ts

73 lines1.9 KB

1import { ProviderInstanceId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { cursorSdkModelSelection } from "./sdkModel.ts";
5import { buildCursorDiscoveredModelsFromSdk } from "./status.ts";
6​
7const instanceId = ProviderInstanceId.make("cursor");
8const models = buildCursorDiscoveredModelsFromSdk([
9 {
10 id: "grok-4.5",
11 displayName: "Grok 4.5",
12 parameters: [
13 {
14 id: "effort",
15 displayName: "Effort",
16 values: [{ value: "low" }, { value: "medium" }, { value: "high" }],
17 },
18 { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] },
19 ],
20 variants: [
21 {
22 displayName: "Grok 4.5 High Fast",
23 isDefault: true,
24 params: [
25 { id: "effort", value: "high" },
26 { id: "fast", value: "true" },
27 ],
28 },
29 ],
30 },
31]);
32​
33describe("cursorSdkModelSelection", () => {
34 it.each([
35 {
36 name: "fills unset catalog parameters and keeps Fast off",
37 options: undefined,
38 params: [
39 { id: "effort", value: "high" },
40 { id: "fast", value: "false" },
41 ],
42 },
43 {
44 name: "keeps explicit options",
45 options: [
46 { id: "effort", value: "low" },
47 { id: "fastMode", value: true },
48 ],
49 params: [
50 { id: "effort", value: "low" },
51 { id: "fast", value: "true" },
52 ],
53 },
54 ])("$name", ({ options, params }) => {
55 const selection = cursorSdkModelSelection(
56 { instanceId, model: "grok-4.5", ...(options === undefined ? {} : { options }) },
57 models,
58 );
59 expect({
60 ...selection,
61 params: selection.params?.toSorted((a, b) => a.id.localeCompare(b.id)),
62 }).toEqual({
63 id: "grok-4.5",
64 params,
65 });
66 });
67​
68 it("sends no parameters for a model missing from the catalog", () => {
69 expect(cursorSdkModelSelection({ instanceId, model: "auto" }, models)).toEqual({
70 id: "default",
71 });
72 });
73});