@skyramp/mcp
Version:
Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution
33 lines (32 loc) • 1.39 kB
JavaScript
// @ts-ignore
import { validateParams } from "./utils.js";
describe("validateParams", () => {
it("should return null for valid comma-separated key=value pairs", () => {
const result = validateParams("foo=bar,baz=qux", "testField");
expect(result).toBeNull();
});
it("should return null for empty string", () => {
const result = validateParams("", "testField");
expect(result).toBeNull();
});
it("should return error for JSON-like input", () => {
const result = validateParams('{"foo":"bar"}', "testField");
expect(result?.isError).toBe(true);
expect(result?.content?.[0].text).toMatch(/not a JSON object/);
});
it("should return error for missing value", () => {
const result = validateParams("foo=", "testField");
expect(result?.isError).toBe(true);
expect(result?.content?.[0].text).toMatch(/key=value/);
});
it("should return error for missing key", () => {
const result = validateParams("=bar", "testField");
expect(result?.isError).toBe(true);
expect(result?.content?.[0].text).toMatch(/key=value/);
});
it("should return error for missing key and value", () => {
const result = validateParams("=", "testField");
expect(result?.isError).toBe(true);
expect(result?.content?.[0].text).toMatch(/key=value/);
});
});