// @ts-ignore
import { validateParams, generateSkyrampHeader } 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);
        const firstContent = result?.content?.[0];
        expect(firstContent?.type).toBe("text");
        if (firstContent?.type === "text") {
            expect(firstContent.text).toMatch(/key=value/);
        }
    });
    it("should return error for missing value", () => {
        const result = validateParams("foo=", "testField");
        expect(result?.isError).toBe(true);
        const firstContent = result?.content?.[0];
        expect(firstContent?.type).toBe("text");
        if (firstContent?.type === "text") {
            expect(firstContent.text).toMatch(/key=value/);
        }
    });
    it("should return error for missing key", () => {
        const result = validateParams("=bar", "testField");
        expect(result?.isError).toBe(true);
        const firstContent = result?.content?.[0];
        expect(firstContent?.type).toBe("text");
        if (firstContent?.type === "text") {
            expect(firstContent.text).toMatch(/key=value/);
        }
    });
    it("should return error for missing key and value", () => {
        const result = validateParams("=", "testField");
        expect(result?.isError).toBe(true);
        const firstContent = result?.content?.[0];
        expect(firstContent?.type).toBe("text");
        if (firstContent?.type === "text") {
            expect(firstContent.text).toMatch(/key=value/);
        }
    });
});
describe("generateSkyrampHeader", () => {
    it("should generate correct header for Python", () => {
        const header = generateSkyrampHeader("python");
        expect(header).toMatch(/^# Generated by Skyramp on/);
        expect(header).toContain("\n\n");
    });
    it("should generate correct header for JavaScript", () => {
        const header = generateSkyrampHeader("javascript");
        expect(header).toMatch(/^\/\/ Generated by Skyramp on/);
        expect(header).toContain("\n\n");
    });
    it("should generate correct header for TypeScript", () => {
        const header = generateSkyrampHeader("typescript");
        expect(header).toMatch(/^\/\/ Generated by Skyramp on/);
        expect(header).toContain("\n\n");
    });
    it("should generate correct header for Java", () => {
        const header = generateSkyrampHeader("java");
        expect(header).toMatch(/^\/\/ Generated by Skyramp on/);
        expect(header).toContain("\n\n");
    });
    it("should generate correct header for unknown language", () => {
        const header = generateSkyrampHeader("unknown");
        expect(header).toMatch(/^# Generated by Skyramp on/);
        expect(header).toContain("\n\n");
    });
    it("should include timestamp in header", () => {
        const header = generateSkyrampHeader("python");
        // Check that the header contains a timestamp in the expected format
        expect(header).toMatch(/on \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}/);
        expect(header).toMatch(/Generated by Skyramp/);
    });
});
