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

ProviderModelsSection.test.ts

39 lines1.4 KB

1import { describe, expect, it } from "vite-plus/test";
2import type { ServerProviderModel } from "@t3tools/contracts";
3​
4import { groupModelsForDisplay, nextHiddenModelsForBulkToggle } from "./ProviderModelsSection";
5​
6function model(slug: string, isCustom = false): ServerProviderModel {
7 return { slug, name: slug, isCustom, capabilities: null };
8}
9​
10describe("groupModelsForDisplay", () => {
11 it("lists favorites first, then visible models in user order, then hidden ones", () => {
12 const models = [model("a"), model("b"), model("c"), model("d"), model("custom", true)];
13​
14 const display = groupModelsForDisplay(models, {
15 favoriteModels: new Set(["c"]),
16 hiddenModels: new Set(["a", "custom"]),
17 modelOrder: ["d", "b"],
18 });
19​
20 expect(display.map((entry) => entry.slug)).toEqual(["c", "d", "b", "custom", "a"]);
21 });
22});
23​
24describe("nextHiddenModelsForBulkToggle", () => {
25 it("hides every built-in model without hiding custom models", () => {
26 const models = [model("a"), model("b"), model("custom", true)];
27​
28 expect(nextHiddenModelsForBulkToggle(models, ["a"])).toEqual(["a", "b"]);
29 });
30​
31 it("shows every built-in model while preserving unrelated hidden entries", () => {
32 const models = [model("a"), model("b"), model("custom", true)];
33​
34 expect(nextHiddenModelsForBulkToggle(models, ["a", "b", "legacy", "custom"])).toEqual([
35 "legacy",
36 "custom",
37 ]);
38 });
39});