feat(import): Packt parser and packt-video job
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34f27d05c9
commit
07e2223c8a
8 files changed
+473
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { parsePacktIndex } from "../src/packt";
|
||||
import { packtIndexHtml } from "./fixtures";
|
||||
|
||||
test("sections, clip titles and video files come from the structure", () => {
|
||||
const p = parsePacktIndex(packtIndexHtml());
|
||||
expect(p.title).toBe("Fake Docker Course");
|
||||
expect(p.sections.map((s) => s.title)).toEqual(["Intro to Docker", "Images (Sample)"]);
|
||||
expect(p.sections[0]!.clips).toEqual([
|
||||
{ number: 1, title: "Course Introduction", video: "videos/video1_1.mp4" },
|
||||
{ number: 2, title: "Docker & Friends", video: "videos/video1_2.mp4" },
|
||||
]);
|
||||
expect(p.sections[1]!.clips[0]!.video).toBe("videos/video2_1.mp4");
|
||||
expect(p.warnings).toEqual([]);
|
||||
});
|
||||
|
||||
test("a section without a chapter block falls back to the overview list", () => {
|
||||
const p = parsePacktIndex(packtIndexHtml({ dropChapter: 1 }));
|
||||
expect(p.sections[0]!.clips.map((c) => [c.title, c.video])).toEqual([
|
||||
["Course Introduction", "videos/video1_1.mp4"],
|
||||
["Docker & Friends", "videos/video1_2.mp4"],
|
||||
]);
|
||||
expect(p.warnings.join()).toContain("section 1 has no chapter block");
|
||||
});
|
||||
|
||||
test("not a Packt page is a clear error", () => {
|
||||
expect(() => parsePacktIndex("<html><h1>Hello</h1></html>")).toThrow(/no "Section N/);
|
||||
});
|
||||
Reference in new issue
Block a user