import { describe, it } from "node:test";
import assert from "node:assert";
// Mock the Anthropic SDK for testing
const mockResponse = {
content: [
{
type: "text",
text: JSON.stringify({
description: "Experience unparalleled comfort with our Ergonomic Office Chair. Designed for professionals who spend long hours at their desk, this chair features advanced lumbar support and breathable mesh back.",
bullets: [
"Adjustable lumbar support for personalized comfort",
"Breathable mesh back keeps you cool all day",
"360-degree swivel with smooth-rolling casters",
"Height-adjustable armrests reduce shoulder strain",
"5-year warranty for lasting peace of mind",
],
metaTitle: "Ergonomic Office Chair - Premium Lumbar Support",
metaDescription: "Upgrade your workspace with our ergonomic office chair. Features adjustable lumbar support and breathable mesh. Shop now!",
keywords: [
"ergonomic office chair",
"lumbar support chair",
"mesh back office chair",
"adjustable desk chair",
"comfortable work chair",
"office furniture",
],
}),
},
],
};
describe("CopyForge MCP", () => {
it("should have valid tool schema", () => {
const toolSchema = {
name: "generate_product_copy",
inputSchema: {
type: "object",
properties: {
product_name: { type: "string" },
features: { type: "string" },
tone: { type: "string", enum: ["professional", "casual", "luxury", "playful", "minimal"] },
platform: { type: "string", enum: ["shopify", "amazon", "etsy", "ebay", "woocommerce", "general"] },
},
required: ["product_name", "features"],
},
};
assert.strictEqual(toolSchema.name, "generate_product_copy");
assert.ok(toolSchema.inputSchema.properties.product_name);
assert.ok(toolSchema.inputSchema.properties.features);
assert.ok(toolSchema.inputSchema.properties.tone);
assert.ok(toolSchema.inputSchema.properties.platform);
assert.deepStrictEqual(toolSchema.inputSchema.required, ["product_name", "features"]);
});
it("should parse valid JSON response", () => {
const textContent = mockResponse.content[0];
assert.strictEqual(textContent.type, "text");
const parsed = JSON.parse(textContent.text);
assert.ok(parsed.description);
assert.ok(Array.isArray(parsed.bullets));
assert.strictEqual(parsed.bullets.length, 5);
assert.ok(parsed.metaTitle);
assert.ok(parsed.metaDescription);
assert.ok(Array.isArray(parsed.keywords));
});
it("should calculate word count correctly", () => {
const textContent = mockResponse.content[0];
const parsed = JSON.parse(textContent.text);
const allText = `${parsed.description} ${parsed.bullets.join(" ")}`;
const wordCount = allText.split(/\s+/).filter(Boolean).length;
assert.ok(wordCount > 0);
assert.ok(typeof wordCount === "number");
});
it("should validate tone options", () => {
const validTones = ["professional", "casual", "luxury", "playful", "minimal"];
validTones.forEach((tone) => {
assert.ok(validTones.includes(tone));
});
});
it("should validate platform options", () => {
const validPlatforms = ["shopify", "amazon", "etsy", "ebay", "woocommerce", "general"];
validPlatforms.forEach((platform) => {
assert.ok(validPlatforms.includes(platform));
});
});
});
console.log("All tests passed!");