mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-03-25 09:25:47 +00:00
- Add npm run inspector script for MCP inspector tool - Synchronize Swift CLI version with package.json (1.0.0-beta.9) - Update macOS version requirement to v14 (Sonoma) for n-1 support - Add Swift compiler warnings check in prepare-release script - Convert tests/setup.ts from Jest to Vitest syntax - Update server status tests to match new format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
59 lines
No EOL
2.7 KiB
TypeScript
59 lines
No EOL
2.7 KiB
TypeScript
import { generateServerStatusString } from "../../../src/utils/server-status";
|
|
|
|
describe("Server Status Utility - generateServerStatusString", () => {
|
|
const testVersion = "1.2.3";
|
|
|
|
beforeEach(() => {
|
|
// Clear the environment variable before each test
|
|
delete process.env.PEEKABOO_AI_PROVIDERS;
|
|
});
|
|
|
|
it("should return status with default providers text when PEEKABOO_AI_PROVIDERS is not set", () => {
|
|
const status = generateServerStatusString(testVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${testVersion} using None Configured. Set PEEKABOO_AI_PROVIDERS ENV.`);
|
|
});
|
|
|
|
it("should return status with default providers text when PEEKABOO_AI_PROVIDERS is an empty string", () => {
|
|
process.env.PEEKABOO_AI_PROVIDERS = "";
|
|
const status = generateServerStatusString(testVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${testVersion} using None Configured. Set PEEKABOO_AI_PROVIDERS ENV.`);
|
|
});
|
|
|
|
it("should return status with default providers text when PEEKABOO_AI_PROVIDERS is whitespace", () => {
|
|
process.env.PEEKABOO_AI_PROVIDERS = " ";
|
|
const status = generateServerStatusString(testVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${testVersion} using None Configured. Set PEEKABOO_AI_PROVIDERS ENV.`);
|
|
});
|
|
|
|
it("should list a single provider from PEEKABOO_AI_PROVIDERS", () => {
|
|
process.env.PEEKABOO_AI_PROVIDERS = "ollama/llava";
|
|
const status = generateServerStatusString(testVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${testVersion} using ollama/llava`);
|
|
});
|
|
|
|
it("should list multiple providers from PEEKABOO_AI_PROVIDERS, trimmed and joined", () => {
|
|
process.env.PEEKABOO_AI_PROVIDERS = "ollama/llava, openai/gpt-4o";
|
|
const status = generateServerStatusString(testVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${testVersion} using ollama/llava, openai/gpt-4o`);
|
|
});
|
|
|
|
it("should handle extra whitespace and empty segments in PEEKABOO_AI_PROVIDERS", () => {
|
|
process.env.PEEKABOO_AI_PROVIDERS =
|
|
" ollama/llava , ,, openai/gpt-4o ,anthropic/claude ";
|
|
const status = generateServerStatusString(testVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${testVersion} using ollama/llava, openai/gpt-4o, anthropic/claude`);
|
|
});
|
|
|
|
it("should correctly include the provided version string", () => {
|
|
const customVersion = "z.y.x";
|
|
const status = generateServerStatusString(customVersion);
|
|
expect(status).toBe(`Peekaboo MCP ${customVersion} using None Configured. Set PEEKABOO_AI_PROVIDERS ENV.`);
|
|
});
|
|
|
|
it("should produce a trimmed string", () => {
|
|
const status = generateServerStatusString("0.0.1");
|
|
expect(status).not.toMatch(/^\s/); // No leading whitespace
|
|
expect(status).not.toMatch(/\s$/); // No trailing whitespace
|
|
expect(status.startsWith("Peekaboo MCP")).toBe(true);
|
|
});
|
|
}); |