Files
cloud-mcp/tests/unit/tools/family/baby.test.ts

71 lines
2.0 KiB
TypeScript

/**
* Baby tools tests
*/
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
import { registerBabyTools } from "../../../../src/tools/family/baby.js";
import { callTool } from "../../../helpers/tool-helper.js";
import { createTempDir } from "../../../helpers/test-utils.js";
import { setupTestDatabase } from "../../../helpers/database-helper.js";
describe("Baby Tools", () => {
let testContext: ReturnType<typeof createTempDir>;
let cleanupDb: () => void;
beforeEach(() => {
testContext = createTempDir();
cleanupDb = setupTestDatabase(testContext);
registerBabyTools();
});
afterEach(() => {
cleanupDb();
testContext.cleanup();
});
test("should add baby milestone", async () => {
const result = await callTool("baby_milestone_add", {
title: "First Steps",
description: "Baby took first steps today",
date: "2024-01-01",
});
expect(result.content[0].text).toContain("recorded successfully");
expect(result.content[0].text).toContain("First Steps");
});
test("should list baby milestones", async () => {
// Add a milestone first
await callTool("baby_milestone_add", {
title: "First Steps",
description: "Baby took first steps",
date: "2024-01-01",
});
const result = await callTool("baby_milestone_list", {});
expect(result.content[0].text).toContain("Total");
expect(result.content[0].text).toContain("First Steps");
});
test("should set baby reminder", async () => {
const result = await callTool("baby_reminder_set", {
title: "Vaccine",
description: "DTaP vaccine due",
date: "2024-02-01",
type: "vaccine",
});
expect(result.content[0].text).toContain("reminder set successfully");
expect(result.content[0].text).toContain("Vaccine");
});
test("should handle empty milestones list", async () => {
const result = await callTool("baby_milestone_list", {});
expect(result.content[0].text).toMatch(
/No milestones recorded|Use baby_milestone_add/i
);
});
});