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).
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { YouTubeClient, type YouTubeSurface } from "../src/client.js";
|
|
|
|
function makeSurface(): YouTubeSurface {
|
|
return {
|
|
subscriptions: vi.fn(async () => [{ videoId: "v1", title: "Sub channel", channel: "c1" }]),
|
|
channelVideos: vi.fn(async () => [{ videoId: "v2", title: "Latest" }]),
|
|
search: vi.fn(async () => [{ videoId: "v3", title: "Result" }]),
|
|
stats: vi.fn(async () => ({ videoId: "v1", viewCount: "100", likeCount: "5", commentCount: "1" })),
|
|
};
|
|
}
|
|
|
|
describe("YouTubeClient", () => {
|
|
it("subscriptions delegates to surface", async () => {
|
|
const s = makeSurface();
|
|
const c = new YouTubeClient({ apiKey: "k", surface: s });
|
|
const out = await c.subscriptions(10);
|
|
expect(out[0]?.videoId).toBe("v1");
|
|
expect(s.subscriptions).toHaveBeenCalledWith(10);
|
|
});
|
|
|
|
it("transcript uses injected fn", async () => {
|
|
const c = new YouTubeClient({
|
|
apiKey: "k",
|
|
surface: makeSurface(),
|
|
transcriptFn: async () => [{ text: "hi", offset: 0, duration: 1 }],
|
|
});
|
|
const out = await c.transcript("vid");
|
|
expect(out).toHaveLength(1);
|
|
});
|
|
|
|
it("stats returns video statistics", async () => {
|
|
const c = new YouTubeClient({ apiKey: "k", surface: makeSurface() });
|
|
const out = await c.stats("v1");
|
|
expect(out.viewCount).toBe("100");
|
|
});
|
|
});
|