This repository was archived by the owner on Nov 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCatManga.test.ts
More file actions
90 lines (73 loc) · 3.29 KB
/
CatManga.test.ts
File metadata and controls
90 lines (73 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import cheerio from "cheerio";
import {CatManga} from "../CatManga/CatManga";
import {APIWrapper, Source} from "paperback-extensions-common";
describe("CatManga Tests", function () {
let wrapper: APIWrapper = new APIWrapper();
let source: Source = new CatManga(cheerio);
let chai = require("chai"),
expect = chai.expect;
let chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
let mangaId = "saint";
it("Retrieve Manga Details", async () => {
let details = await wrapper.getMangaDetails(source, mangaId);
expect(
details,
"No results found with test-defined ID [" + mangaId + "]"
).to.exist;
// Validate that the fields are filled
let data = details;
expect(data.id, "Missing ID").to.be.not.empty;
expect(data.image, "Missing Image").to.exist;
expect(data.status, "Missing Status").to.exist;
expect(data.titles, "Missing Titles").to.be.not.empty;
expect(data.rating, "Missing Rating").to.exist;
expect(data.desc, "Missing Description").to.be.not.empty;
});
it("Get Chapters", async () => {
let data = await wrapper.getChapters(source, mangaId);
expect(data, "No chapters present for: [" + mangaId + "]").to.not.be.empty;
let entry = data[0];
expect(entry.id, "No ID present").to.not.be.empty;
expect(entry.chapNum, "No chapter number present").to.exist;
});
it("Get Chapter Details", async () => {
let chapters = await wrapper.getChapters(source, mangaId);
let data = await wrapper.getChapterDetails(source, mangaId, chapters[0].id);
expect(data, "Empty server response").to.not.be.empty;
expect(data.id, "Missing ID").to.be.not.empty;
expect(data.mangaId, "Missing MangaID").to.be.not.empty;
expect(data.pages, "No pages present").to.be.not.empty;
});
it("Testing search", async () => {
let testSearch = createSearchRequest({
title: "komi",
});
let search = await wrapper.searchRequest(source, testSearch);
let result = search.results[0];
expect(result, "No response from server").to.exist;
expect(result.id, "No ID found for search query").to.be.not.empty;
expect(result.title, "No title").to.be.not.empty;
});
it("Testing Home Page", async () => {
let result = await wrapper.getHomePageSections(source);
expect(result, "No response from server").to.exist;
let item = result[0];
expect(item, "Empty response from server").to.exist;
if (item.items) {
let subitem = item.items[0];
expect(subitem.id, "No ID found for homepage item").to.not.be.empty;
expect(subitem.title, "No Title found for homepage item").to.not.be.empty;
expect(subitem.image, "No Image found for homepage item").to.not.be.empty;
}
})
// TODO: Wait for upload times to be shown.
/*
it("Testing Notifications", async () => {
let updates = await wrapper.filterUpdatedManga(source, new Date("2021-4-5"), [mangaId])
expect(updates, "No server response").to.exist
expect(updates, "Empty server response").to.not.be.empty
expect(updates[0], "No updates").to.not.be.empty;
})
*/
});