File size: 1,767 Bytes
3201ca6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import { describe, expect, it } from "vitest";
import {
readProfileMcpRefs,
sameScopeSelection,
} from "#/constants/profile-scope";
describe("readProfileMcpRefs", () => {
it("reads an absent field as the server default", () => {
expect(readProfileMcpRefs(undefined)).toEqual({
mode: "standard",
selected: [],
});
expect(readProfileMcpRefs(null)).toEqual({
mode: "standard",
selected: [],
});
});
it("reads an empty array as an explicit no-servers scope", () => {
expect(readProfileMcpRefs([])).toEqual({ mode: "custom", selected: [] });
});
it("reads a list as the selection", () => {
expect(readProfileMcpRefs(["github", "postgres"])).toEqual({
mode: "custom",
selected: ["github", "postgres"],
});
});
it("drops non-string entries rather than failing the editor", () => {
expect(readProfileMcpRefs(["github", 7, null])).toEqual({
mode: "custom",
selected: ["github"],
});
});
});
describe("sameScopeSelection", () => {
it("ignores order, which the resolver does not use", () => {
expect(
sameScopeSelection(["github", "postgres"], ["postgres", "github"]),
).toBe(true);
});
it("ignores a repeated name, which the resolver collapses", () => {
expect(sameScopeSelection(["github"], ["github", "github"])).toBe(true);
});
it("still sees an added or removed server", () => {
expect(sameScopeSelection(["github"], ["github", "postgres"])).toBe(false);
expect(sameScopeSelection(["github"], ["postgres"])).toBe(false);
});
it("treats an empty selection as equal only to another empty one", () => {
expect(sameScopeSelection([], [])).toBe(true);
expect(sameScopeSelection([], ["github"])).toBe(false);
});
});
|