formalize unit testing stuff and expose more metadata in Work
parent
c1bfcddeab
commit
3723f1063a
@ -1,7 +1,7 @@
|
|||||||
import AO3 from "./src/classes/AO3.ts";
|
import AO3 from "./src/classes/AO3.ts";
|
||||||
export default AO3;
|
export default AO3;
|
||||||
|
|
||||||
export * from "./src/classes/AO3.ts";
|
import Chapter from "./src/classes/Chapter.ts";
|
||||||
export * from "./src/classes/Chapter.ts";
|
import Search from "./src/classes/Search.ts";
|
||||||
export * from "./src/classes/Search.ts";
|
import Work from "./src/classes/Work.ts";
|
||||||
export * from "./src/classes/Work.ts";
|
export { AO3, Chapter, Search, Work };
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
//FIXME: we need to test single-chapter works too (because those seem to be really inconsistent for some reason?)
|
||||||
|
import AO3 from "../mod.ts";
|
||||||
|
import { Work } from "../mod.ts";
|
||||||
|
import { assert } from "https://deno.land/std@0.167.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
export default async function test(ao3: AO3) {
|
||||||
|
await Deno.test("chapters", async (test) => {
|
||||||
|
const work = await ao3.getWork("43251729");
|
||||||
|
await work.init();
|
||||||
|
|
||||||
|
assert(work.chapters.length > 0, "chapters array is not initialized");
|
||||||
|
await test.step("IDs", async () => {
|
||||||
|
assert(
|
||||||
|
await work.chapters[0].id === "108714198",
|
||||||
|
"incorrect chapter ID",
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
await work.chapters[0].workID === "43251729",
|
||||||
|
"incorrect work ID",
|
||||||
|
); //why do we even store the work's ID publicly in a chapter?
|
||||||
|
});
|
||||||
|
await test.step("name", async () => {
|
||||||
|
assert(
|
||||||
|
await work.chapters[0].name === "Welcome to the Studio",
|
||||||
|
"incorrect/missing chapter names",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await test.step("content", async () => {
|
||||||
|
//FIXME: this should probably be tested better
|
||||||
|
assert(
|
||||||
|
(await work.chapters[0].text).length > 0,
|
||||||
|
"text/content is completely missing",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await test.step("notes and summary", async () => {
|
||||||
|
//FIXME: write a chapter of my fic (lol) that includes a summary and end note for testing
|
||||||
|
assert(
|
||||||
|
await work.chapters[3].startNote ===
|
||||||
|
`If you haven't noticed yet, most of these chapters are named after Bendy fansongs
|
||||||
|
|
||||||
|
|
||||||
|
This is definitely because I'm trying to be smart and cool and make funny references, and definitely not because I'm uncreative :)`,
|
||||||
|
"incorrect start note parsing",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
import AO3 from "../src/classes/AO3.ts";
|
||||||
|
import workTest from "./work.ts";
|
||||||
|
import chaptersTest from "./chapter.ts";
|
||||||
|
|
||||||
|
const ao3 = new AO3();
|
||||||
|
|
||||||
|
await workTest(ao3);
|
||||||
|
await chaptersTest(ao3);
|
@ -0,0 +1,50 @@
|
|||||||
|
import AO3 from "../mod.ts";
|
||||||
|
import type { Work } from "../mod.ts";
|
||||||
|
import { assert } from "https://deno.land/std@0.167.0/testing/asserts.ts";
|
||||||
|
|
||||||
|
export default async function test(ao3: AO3) {
|
||||||
|
await Deno.test("works", async (test) => {
|
||||||
|
let work: Work;
|
||||||
|
await test.step("initialization", async () => {
|
||||||
|
work = await ao3.getWork("43251729");
|
||||||
|
await work.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step("tags", async (test) => {
|
||||||
|
assert(work.tags.length > 0, "Failed to parse any tags");
|
||||||
|
await test.step("fandoms", () => {
|
||||||
|
assert(
|
||||||
|
work.tags.includes("Bendy and the Ink Machine"),
|
||||||
|
"Failed to get correct fandom tags",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await test.step("characters", () => {
|
||||||
|
assert(
|
||||||
|
work.tags.includes("Bendy (Bendy and the Ink Machine)"),
|
||||||
|
"Failed to get correct character tags",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await test.step("ships", () => {
|
||||||
|
assert(
|
||||||
|
work.tags.includes(
|
||||||
|
"Bendy (Bendy and the Ink Machine)/Reader",
|
||||||
|
),
|
||||||
|
"Failed to get correct ship tags",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await test.step("freeforms", () => {
|
||||||
|
assert(
|
||||||
|
work.tags.includes("no beta read we die like sammy"),
|
||||||
|
"Failed to get correct freeform tags",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
await test.step("other metadata", () => {
|
||||||
|
assert(
|
||||||
|
work.name === "Inky Desires [Bendy X Reader]",
|
||||||
|
"incorrect work name",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in new issue