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

modelTraits.test.ts

35 lines1.5 KB

1import type { ProviderOptionDescriptor } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { buildTraitsTriggerDisplay, getDescriptorStringValue } from "./modelTraits.ts";
5​
6describe("buildTraitsTriggerDisplay", () => {
7 it.each([
8 { currentValue: undefined, defaultValue: undefined, value: null, label: "Thinking" },
9 { currentValue: undefined, defaultValue: "high", value: "high", label: "High" },
10 { currentValue: "low", defaultValue: undefined, value: "low", label: "Low" },
11 { currentValue: "max", defaultValue: "high", value: "max", label: "Max" },
12 { id: "effort", currentValue: undefined, defaultValue: undefined, value: null, label: "" },
13 ])("labels Pi thinking without inventing a selection: $label ($value)", (input) => {
14 const descriptor: Extract<ProviderOptionDescriptor, { type: "select" }> = {
15 id: input.id ?? "thinking",
16 label: "Thinking",
17 type: "select",
18 options: ["low", "high", "max"].map((id) => ({
19 id,
20 label: id[0]!.toUpperCase() + id.slice(1),
21 ...(id === input.defaultValue ? { isDefault: true } : {}),
22 })),
23 ...(input.currentValue ? { currentValue: input.currentValue } : {}),
24 };
25​
26 expect(
27 buildTraitsTriggerDisplay({
28 descriptors: [descriptor],
29 primarySelectDescriptorId: descriptor.id,
30 ultrathinkPromptControlled: false,
31 }).label,
32 ).toBe(input.label);
33 expect(getDescriptorStringValue(descriptor)).toBe(input.value);
34 });
35});