44 lines
2.5 KiB
TypeScript
44 lines
2.5 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { ageGateTarget, episodeSeriesId, extractCovers, parseInfoPage } from "../src/core/sources/tapas/parse";
|
|
import { fixtureText } from "./helpers/fixtures";
|
|
|
|
const INFO = new URL("https://tapas.io/series/villains-are-destined-to-die/info");
|
|
|
|
test("comic info page: id, title, type, the portrait original and the banner", async () => {
|
|
const page = parseInfoPage(await fixtureText("tapas/villains-info.html"), INFO);
|
|
expect(page).toMatchObject({
|
|
id: "186414", title: "Villains Are Destined to Die", novel: false,
|
|
canonicalUrl: "https://tapas.io/series/villains-are-destined-to-die/info",
|
|
});
|
|
expect(page.covers.map((c) => [c.role, c.url])).toEqual([
|
|
["poster", "https://us-a.tapas.io/sa/d1/e57ba991-1815-41f4-99b8-70057b563642.jpg"],
|
|
["banner", "https://us-a.tapas.io/sa/60/4cb8adab-92ea-4b38-b814-94d3d5606bf5.jpg"],
|
|
]);
|
|
expect(page.covers[0]!.originalUrl).toBe("https://us-a.tapas.io/sa/d1/e57ba991-1815-41f4-99b8-70057b563642_z.jpg");
|
|
});
|
|
|
|
test("novel info page", async () => {
|
|
const page = parseInfoPage(await fixtureText("tapas/villains-novel-info.html"), new URL("https://tapas.io/series/villains-are-destined-to-die-novel/info"));
|
|
expect(page).toMatchObject({ id: "266599", title: "Villains Are Destined to Die", novel: true });
|
|
expect(page.covers.map((c) => c.role)).toEqual(["poster", "banner"]);
|
|
});
|
|
|
|
test("a 2020 archived page (the reader layout, CloudFront images)", async () => {
|
|
const covers = extractCovers(await fixtureText("wayback/tapas-villains-2020.html"), new URL("https://tapas.io/series/villains-are-destined-to-die"));
|
|
expect(covers.map((c) => [c.role, c.url])).toEqual([
|
|
["poster", "https://us-a.tapas.io/sa/c6/8eca19f0-84e2-4d86-bc5e-c2d7ffa6fd1c.jpg"],
|
|
["banner", "https://us-a.tapas.io/sa/b7/3fc9b35a-1dc3-4410-973f-f6286bb41041.jpg"],
|
|
]);
|
|
expect(covers[0]!.originalUrl).toBe("https://d30womf5coomej.cloudfront.net/sa/c6/8eca19f0-84e2-4d86-bc5e-c2d7ffa6fd1c_z.jpg");
|
|
});
|
|
|
|
test("the episode reader names its series", async () => {
|
|
expect(episodeSeriesId(await fixtureText("tapas/villains-episode-viewer.html"))).toBe("186414");
|
|
expect(episodeSeriesId("<html></html>")).toBeNull();
|
|
});
|
|
|
|
test("the age check names the series it stands in front of", async () => {
|
|
expect(ageGateTarget(await fixtureText("tapas/verify-age-dog-and-bird.html"))).toBe("https://tapas.io/series/dog-and-bird-mature/info");
|
|
expect(ageGateTarget(await fixtureText("tapas/villains-info.html"))).toBeNull();
|
|
});
|