35 lines
1002 B
TypeScript
35 lines
1002 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { parseClientConfiguration } from "./ClientConfigurationDocument.js";
|
|
|
|
describe("parseClientConfiguration shape diagnostics", () => {
|
|
it.each([
|
|
["null", "null"],
|
|
["array", "[]"],
|
|
["string", '"x"'],
|
|
] as const)("names a non-object JSON root (%s)", (_label, text) => {
|
|
expect(() => parseClientConfiguration(text, "json")).toThrow(
|
|
new TypeError("The configuration root must be an object"),
|
|
);
|
|
});
|
|
|
|
it.each([
|
|
["null", "null"],
|
|
["array", "[]"],
|
|
["string", '"x"'],
|
|
] as const)(
|
|
'names a non-object "mcpServers" value (%s)',
|
|
(_label, servers) => {
|
|
expect(() =>
|
|
parseClientConfiguration(`{"mcpServers":${servers},"keep":1}`, "json"),
|
|
).toThrow(new TypeError('"mcpServers" must be an object'));
|
|
},
|
|
);
|
|
|
|
it("still rejects unparsable JSON with SyntaxError", () => {
|
|
expect(() => parseClientConfiguration("not-json", "json")).toThrow(
|
|
SyntaxError,
|
|
);
|
|
});
|
|
});
|