1import { describe, expect, it } from "vite-plus/test";
2
3import type { ModelCapabilities } from "@t3tools/contracts";
4
5import { applyProviderOptionSelection, resolveProviderOptionDescriptors } from "./providerOptions";
6
7const CODEX_CAPABILITIES: ModelCapabilities = {
8 optionDescriptors: [
9 {
10 id: "reasoningEffort",
11 label: "Reasoning",
12 type: "select",
13 options: [
14 { id: "medium", label: "Medium", isDefault: true },
15 { id: "high", label: "High" },
16 ],
17 currentValue: "medium",
18 },
19 {
20 id: "serviceTier",
21 label: "Service Tier",
22 type: "select",
23 options: [
24 { id: "default", label: "Standard", isDefault: true },
25 { id: "priority", label: "Fast" },
26 ],
27 currentValue: "default",
28 },
29 ],
30};
31
32describe("mobile provider options", () => {
33 it("updates generic select options without knowing provider-specific ids", () => {
34 const descriptors = resolveProviderOptionDescriptors({
35 capabilities: CODEX_CAPABILITIES,
36 selections: undefined,
37 });
38
39 expect(
40 applyProviderOptionSelection(descriptors, { id: "serviceTier", value: "priority" }),
41 ).toEqual([
42 { id: "reasoningEffort", value: "medium" },
43 { id: "serviceTier", value: "priority" },
44 ]);
45 // Choices the model doesn't advertise are rejected, not stored.
46 expect(
47 applyProviderOptionSelection(descriptors, { id: "serviceTier", value: "turbo" }),
48 ).toBeNull();
49 expect(applyProviderOptionSelection(descriptors, { id: "unknown", value: "high" })).toBeNull();
50 });
51
52 it("updates generic boolean options", () => {
53 const descriptors = resolveProviderOptionDescriptors({
54 capabilities: {
55 optionDescriptors: [{ id: "fastMode", label: "Fast Mode", type: "boolean" }],
56 },
57 selections: undefined,
58 });
59
60 expect(applyProviderOptionSelection(descriptors, { id: "fastMode", value: true })).toEqual([
61 { id: "fastMode", value: true },
62 ]);
63 });
64});