KeiSeiKit-1.0/_ts_packages/packages/recall-adapter/test/tools.test.ts
Parfii-bot c21943e40b feat(ts-packages): 6 TS packages — MCP server + 5 external-API adapters
Total 1465 LOC + 616 test LOC, 78/78 tests pass.
- @keisei/mcp-server (25 tests) — Rust-CLI bridge via execa, stdio+HTTP, HMAC auth, kei() meta-tool
- @keisei/telegram-adapter (16 tests) — grammy Bot, 7 tools
- @keisei/recall-adapter (8 tests) — Zoom via Recall.ai, 5 tools
- @keisei/grok-adapter (6 tests) — xAI OpenAI-compatible, 2 tools
- @keisei/gmail-adapter (11 tests) — googleapis OAuth2, 6 tools (new — LBM gap)
- @keisei/youtube-adapter (12 tests) — YouTube Data API v3, 5 tools (new — LBM gap)

RULE 0.2 exception #4 (TS for MCP/API layer documented in _ts_packages/README.md).
RULE 0.8 — env vars only (TELEGRAM_BOT_TOKEN, XAI_API_KEY, GMAIL_*, YOUTUBE_API_KEY).
Strict TypeScript: strict + exactOptionalPropertyTypes + noUncheckedIndexedAccess.
Genesis-scan clean (0 hits).
2026-04-22 12:45:19 +08:00

47 lines
1.7 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { RecallClient } from "../src/client.js";
import { buildRecallTools } from "../src/tools.js";
function makeFetchMock(payload: unknown): typeof fetch {
return vi.fn(async () => ({
ok: true,
status: 200,
async text() { return JSON.stringify(payload); },
async json() { return payload; },
} as unknown as Response)) as unknown as typeof fetch;
}
describe("recall tool surface", () => {
it("exposes 5 tools", () => {
const c = new RecallClient({ apiKey: "k", fetchImpl: makeFetchMock({}) });
const tools = buildRecallTools(c);
expect(tools.map((t) => t.name)).toEqual([
"zoom_status",
"zoom_bots",
"zoom_join",
"zoom_leave",
"zoom_chat",
]);
});
it("zoom_join validates meeting_url as URL", async () => {
const c = new RecallClient({ apiKey: "k", fetchImpl: makeFetchMock({}) });
const tool = buildRecallTools(c).find((t) => t.name === "zoom_join");
await expect(tool!.handler({ meeting_url: "not a url" })).rejects.toBeTruthy();
});
it("zoom_status returns JSON string", async () => {
const c = new RecallClient({ apiKey: "k", fetchImpl: makeFetchMock({ id: "x" }) });
const tool = buildRecallTools(c).find((t) => t.name === "zoom_status");
const out = await tool!.handler({ bot_id: "x" });
expect(out).toContain('"id": "x"');
});
it("zoom_bots hits list endpoint", async () => {
const fetchImpl = makeFetchMock([{ id: "a" }]);
const c = new RecallClient({ apiKey: "k", fetchImpl });
const tool = buildRecallTools(c).find((t) => t.name === "zoom_bots");
const out = await tool!.handler({});
expect(out).toContain("a");
});
});