import { describe, it, expect } from "@jest/globals";
// Simple validation tests - not mocking Anthropic SDK to avoid type issues
describe("ProofBase MCP Server", () => {
describe("testimonial structure validation", () => {
it("should validate a complete testimonial structure", () => {
const testimonial = {
name: "Sarah Chen",
role: "Marketing Director",
company: "TechFlow",
avatar: "SC",
text: "ProofBase increased our conversion rate by 34%. Setup took 5 minutes!",
rating: 5,
};
expect(testimonial).toHaveProperty("name");
expect(testimonial).toHaveProperty("role");
expect(testimonial).toHaveProperty("company");
expect(testimonial).toHaveProperty("avatar");
expect(testimonial).toHaveProperty("text");
expect(testimonial).toHaveProperty("rating");
expect(testimonial.avatar).toHaveLength(2);
expect(testimonial.rating).toBeGreaterThanOrEqual(1);
expect(testimonial.rating).toBeLessThanOrEqual(5);
});
it("should parse JSON testimonial from API response", () => {
const responseText = JSON.stringify({
name: "Marcus Johnson",
role: "Founder",
company: "StartupX",
avatar: "MJ",
text: "Absolutely game-changing for our landing page.",
rating: 5,
});
const jsonMatch = responseText.match(/\{[\s\S]*\}/);
expect(jsonMatch).not.toBeNull();
const testimonial = JSON.parse(jsonMatch![0]);
expect(testimonial.name).toBe("Marcus Johnson");
expect(testimonial.role).toBe("Founder");
expect(testimonial.company).toBe("StartupX");
});
it("should handle JSON embedded in other text", () => {
const responseText = `Here's the testimonial:
{
"name": "Lisa Wong",
"role": "CTO",
"company": "DevHub",
"avatar": "LW",
"text": "Great product!",
"rating": 5
}
Hope this helps!`;
const jsonMatch = responseText.match(/\{[\s\S]*\}/);
expect(jsonMatch).not.toBeNull();
const testimonial = JSON.parse(jsonMatch![0]);
expect(testimonial.name).toBe("Lisa Wong");
expect(testimonial.rating).toBe(5);
});
});
describe("input validation", () => {
it("should require product_name, customer_type, and outcome", () => {
const validInput = {
product_name: "ProofBase",
customer_type: "SaaS founder",
outcome: "increased conversions",
};
expect(validInput.product_name).toBeDefined();
expect(validInput.customer_type).toBeDefined();
expect(validInput.outcome).toBeDefined();
});
it("should accept optional tone parameter", () => {
const tones = ["professional", "casual", "enthusiastic"] as const;
const inputWithTone = {
product_name: "ProofBase",
customer_type: "Marketing manager",
outcome: "better engagement",
tone: "enthusiastic" as typeof tones[number],
};
expect(tones).toContain(inputWithTone.tone);
});
it("should accept optional include_metrics parameter", () => {
const inputWithMetrics = {
product_name: "ProofBase",
customer_type: "Developer",
outcome: "faster setup",
include_metrics: false,
};
expect(typeof inputWithMetrics.include_metrics).toBe("boolean");
});
it("should detect missing required fields", () => {
const invalidInput = {
product_name: "ProofBase",
// missing customer_type and outcome
};
const hasAllRequired =
"product_name" in invalidInput &&
"customer_type" in invalidInput &&
"outcome" in invalidInput;
expect(hasAllRequired).toBe(false);
});
});
describe("avatar generation", () => {
it("should generate valid 2-letter initials", () => {
const names = [
{ name: "Sarah Chen", expected: "SC" },
{ name: "Marcus Johnson", expected: "MJ" },
{ name: "Aisha Patel", expected: "AP" },
];
names.forEach(({ name, expected }) => {
const parts = name.split(" ");
const initials = parts.map(p => p[0].toUpperCase()).join("").slice(0, 2);
expect(initials).toBe(expected);
expect(initials).toHaveLength(2);
});
});
});
});