diff options
| author | Adam Malczewski <[email protected]> | 2026-06-21 14:58:38 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-21 14:58:38 +0900 |
| commit | dfb3a61afa545b67b85dbefe6b217affd14c16a7 (patch) | |
| tree | fbe0d18323136cc19d971e18f0801428bcd2e4a7 /packages/tool-youtube-transcript/src/validate.test.ts | |
| parent | d56fe9cf64719bb330c17b2daee58c0bafa057c9 (diff) | |
| download | dispatch-dfb3a61afa545b67b85dbefe6b217affd14c16a7.tar.gz dispatch-dfb3a61afa545b67b85dbefe6b217affd14c16a7.zip | |
feat(tool-youtube-transcript): YouTube transcription tool
New standard tool extension backed by a self-hosted transcriber service
(http://100.102.55.49:41090, Tailscale, no API key). One tool
youtube_transcript — fetches transcripts for YouTube videos. Returns
completed (full text + timestamped segments), queued/processing (position
+ ETA + .youtube_subtitles_pending retry convention), or failed (error).
Pure core: validateUrl + format* functions + truncateOutput. Injected
edge: TranscriptClient (injectable fetchFn, AbortSignal.any for
cancellation). concurrencySafe true, capabilities network. 30 tests.
Verified: tsc EXIT 0, 1152 vitest, biome clean (327 files). Boot smoke
clean.
Diffstat (limited to 'packages/tool-youtube-transcript/src/validate.test.ts')
| -rw-r--r-- | packages/tool-youtube-transcript/src/validate.test.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/tool-youtube-transcript/src/validate.test.ts b/packages/tool-youtube-transcript/src/validate.test.ts new file mode 100644 index 0000000..3181bb1 --- /dev/null +++ b/packages/tool-youtube-transcript/src/validate.test.ts @@ -0,0 +1,35 @@ +import { describe, expect, it } from "vitest"; +import { validateUrl } from "./validate.js"; + +describe("validateUrl", () => { + it("accepts valid URL", () => { + const result = validateUrl({ url: "https://www.youtube.com/watch?v=abc123" }); + expect(result).toBe("https://www.youtube.com/watch?v=abc123"); + }); + + it("rejects missing url", () => { + const result = validateUrl({ query: "no url here" }); + expect(typeof result).toBe("object"); + if (typeof result === "object") { + expect(result.error).toContain("url"); + } + }); + + it("rejects empty url", () => { + const empty = validateUrl({ url: "" }); + expect(typeof empty).toBe("object"); + if (typeof empty === "object") { + expect(empty.error).toContain("url"); + } + const whitespace = validateUrl({ url: " " }); + expect(typeof whitespace).toBe("object"); + }); + + it("rejects null/non-object args", () => { + expect(typeof validateUrl(null)).toBe("object"); + expect(typeof validateUrl(undefined)).toBe("object"); + expect(typeof validateUrl("string")).toBe("object"); + expect(typeof validateUrl(42)).toBe("object"); + expect(typeof validateUrl(true)).toBe("object"); + }); +}); |
