Files
t3code/apps/web/src/components/settings/ProviderModelsSection.test.ts
T

24 lines
896 B
TypeScript

import { describe, expect, it } from "vite-plus/test";
import type { ServerProviderModel } from "@t3tools/contracts";
import { groupModelsForDisplay } from "./ProviderModelsSection";
function model(slug: string, isCustom = false): ServerProviderModel {
return { slug, name: slug, isCustom, capabilities: null };
}
describe("groupModelsForDisplay", () => {
it("lists favorites first, then visible models in user order, then hidden ones", () => {
const models = [model("a"), model("b"), model("c"), model("d"), model("custom", true)];
const display = groupModelsForDisplay(models, {
favoriteModels: new Set(["c"]),
hiddenModels: new Set(["a", "custom"]),
modelOrder: ["d", "b"],
});
// A custom model is never hidden, even if its slug is in the hidden set.
expect(display.map((entry) => entry.slug)).toEqual(["c", "d", "b", "custom", "a"]);
});
});