KeiSeiKit-1.0/_ts_packages/packages/youtube-adapter/test/client.test.ts
Parfii-bot a4e667de10 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

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");
});
});