import test from "node:test"; import assert from "node:assert/strict"; import { parseVideoList } from "./videoList"; // Run with: pnpm -C editor exec tsx --test "app/saved-videos/lib/videoList.test.ts" test("slug/id, slug id, slug,id and an editor video link; blanks and # comments skipped; repeats once", () => { const r = parseVideoList( [ "demo-channel/dQw4w9WgXcQ", " other-chan abc_123 ", "", "# a comment", "third,v-1.2", "http://localhost:3001/channels/demo-channel/videos/dQw4w9WgXcQ?tab=x", "https://editor.example/channels/fourth/videos/zz9", ].join("\n"), ); assert.deepEqual(r.items, [ { slug: "demo-channel", id: "dQw4w9WgXcQ" }, { slug: "other-chan", id: "abc_123" }, { slug: "third", id: "v-1.2" }, { slug: "fourth", id: "zz9" }, ]); assert.deepEqual(r.bad, []); }); test("a line that names no channel and video is reported with its line number", () => { const r = parseVideoList("ok/one\njust-one-word\na b c\n../etc passwd\nhttps://youtube.com/watch?v=x"); assert.deepEqual(r.items, [{ slug: "ok", id: "one" }]); assert.deepEqual( r.bad.map((b) => b.line), [2, 3, 4, 5], ); });