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