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 pathSenManga.test.ts
More file actions
119 lines (92 loc) · 4.71 KB
/
SenManga.test.ts
File metadata and controls
119 lines (92 loc) · 4.71 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import cheerio from 'cheerio'
import { APIWrapper, Source } from 'paperback-extensions-common';
import { SenManga } from '../SenManga/SenManga';
describe('SenManga Tests', function () {
var wrapper: APIWrapper = new APIWrapper();
var source: Source = new SenManga(cheerio);
var chai = require('chai'), expect = chai.expect;
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
/**
* The Manga ID which this unit test uses to base it's details off of.
* Try to choose a manga which is updated frequently, so that the historical checking test can
* return proper results, as it is limited to searching 30 days back due to extremely long processing times otherwise.
*/
var mangaId = "Fate-Stay-Night-Heaven%27s-Feel";
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.be.not.empty;
expect(data.status, "Missing Status").to.exist;
expect(data.author, "Missing Author").to.be.not.empty;
expect(data.desc, "Missing Description").to.be.not.empty;
expect(data.titles, "Missing Titles").to.be.not.empty;
expect(data.rating, "Missing Rating").to.exist;
});
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.time, "No date present").to.exist
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, "No server response").to.exist;
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: 'Bokura'
});
let search = await wrapper.searchRequest(source, testSearch, 1);
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.image, "No image found for search").to.be.not.empty;
expect(result.title, "No title").to.be.not.null;
expect(result.subtitleText, "No subtitle text").to.be.not.null;
});
it("Testing Home-Page aquisition", async() => {
let homePages = await wrapper.getHomePageSections(source)
expect(homePages, "No response from server").to.exist
})
it("Testing home page results for latest titles", async() => {
let results = await wrapper.getViewMoreItems(source, "last_update", {}, 1)
expect(results, "No results whatsoever for this section").to.exist
let data = results![0]
expect(data.id, "No ID present").to.exist
expect(data.image, "No image present").to.exist
expect(data.title.text, "No title present").to.exist
})
it("Testing home page results for popular titles", async() => {
let results = await wrapper.getViewMoreItems(source, "popular", {}, 1)
expect(results, "No results whatsoever for this section").to.exist
let data = results![0]
expect(data.id, "No ID present").to.exist
expect(data.image, "No image present").to.exist
expect(data.title.text, "No title present").to.exist
})
it("Testing home page results for new titles", async() => {
let results = await wrapper.getViewMoreItems(source, "new_series", {}, 1)
expect(results, "No results whatsoever for this section").to.exist
let data = results![0]
expect(data.id, "No ID present").to.exist
expect(data.image, "No image present").to.exist
expect(data.title.text, "No title present").to.exist
})
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;
})
})