feature/pi-refactor
 1/**
 2 * Tests for Status Tool
 3 * 
 4 * RED phase: Write these tests first, verify they fail
 5 * GREEN phase: Implement minimal code to pass
 6 * REFACTOR phase: Improve structure while keeping tests green
 7 */
 8
 9import { describe, it, expect } from "vitest";
10import { statusTool } from "./status.js";
11
12describe("Status Tool", () => {
13  it("should have correct tool metadata", () => {
14    expect(statusTool.name).toBe("status");
15    expect(statusTool.label).toBeDefined();
16    expect(statusTool.description).toBeDefined();
17    expect(statusTool.description).toContain("system");
18  });
19
20  it("should have no required parameters", () => {
21    expect(statusTool.parameters).toBeDefined();
22    // Empty object schema = no parameters
23  });
24
25  it("should execute and return system status", async () => {
26    const result = await statusTool.execute(
27      "test-call-id",
28      {},
29      new AbortController().signal,
30      () => {}
31    );
32
33    expect(result).toBeDefined();
34    expect(result.content).toBeDefined();
35    expect(Array.isArray(result.content)).toBe(true);
36    expect(result.content.length).toBeGreaterThan(0);
37  });
38
39  it("should return text content with system info", async () => {
40    const result = await statusTool.execute(
41      "test-call-id",
42      {},
43      new AbortController().signal,
44      () => {}
45    );
46
47    const textContent = result.content.find((c: any) => c.type === "text");
48    expect(textContent).toBeDefined();
49    
50    const text = (textContent as any).text.toLowerCase();
51    expect(text).toContain("uptime");
52    expect(text).toContain("memory");
53    expect(text).toContain("load");
54  });
55
56  it("should include numeric values in status", async () => {
57    const result = await statusTool.execute(
58      "test-call-id",
59      {},
60      new AbortController().signal,
61      () => {}
62    );
63
64    const textContent = result.content.find((c: any) => c.type === "text");
65    const text = (textContent as any).text;
66    
67    // Should contain numbers (uptime seconds, memory MB, load average)
68    expect(text).toMatch(/\d+/);
69  });
70});