generated from kawarimidoll/deno-dev-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
122 lines (105 loc) · 3.24 KB
/
test.ts
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
120
121
122
import { assert } from "./deps.ts";
import {
implementsZennArticle,
implementsZennBook,
implementsZennScrap,
implementsZennTopic,
implementsZennUser,
zennApi,
} from "./mod.ts";
Deno.test("Top page", async () => {
const result = await zennApi();
const { dailyTechArticles, dailyIdeaArticles, dailyBooks } = result;
assert(implementsZennArticle(dailyTechArticles[0]));
assert(implementsZennArticle(dailyIdeaArticles[0]));
assert(implementsZennBook(dailyBooks[0]));
});
Deno.test("User page", async () => {
const result = await zennApi("kawarimidoll");
const { user } = result;
assert(implementsZennUser(user));
});
Deno.test("Articles page", async () => {
const result = await zennApi("articles");
assert(implementsZennArticle(result.articles[0]));
});
Deno.test("Articles/explore page", async () => {
const result = await zennApi("articles/explore");
const {
weeklyTechArticles,
alltimeTechArticles,
weeklyIdeaArticles,
alltimeIdeaArticles,
randomFeaturedArticles,
newArticles,
popularTopics,
} = result;
assert(implementsZennArticle(weeklyTechArticles[0]));
assert(implementsZennArticle(alltimeTechArticles[0]));
assert(implementsZennArticle(weeklyIdeaArticles[0]));
assert(implementsZennArticle(alltimeIdeaArticles[0]));
assert(implementsZennArticle(randomFeaturedArticles[0]));
assert(implementsZennArticle(newArticles[0]));
assert(implementsZennTopic(popularTopics[0]));
});
Deno.test("Specific Article page", async () => {
const result = await zennApi("kawarimidoll/articles/2937f4da6d9fa8");
assert(implementsZennArticle(result.article));
});
Deno.test("Books page", async () => {
const result = await zennApi("books");
assert(implementsZennBook(result.books[0]));
});
Deno.test("Books/explore page", async () => {
const result = await zennApi("books/explore");
const {
randomFeaturedBooks,
freeBooks,
alltimeBooks,
dailyBooks,
} = result;
assert(implementsZennBook(randomFeaturedBooks[0]));
assert(implementsZennBook(freeBooks[0]));
assert(implementsZennBook(alltimeBooks[0]));
assert(implementsZennBook(dailyBooks[0]));
});
Deno.test("Scraps page", async () => {
const result = await zennApi("scraps");
assert(implementsZennScrap(result.scraps[0]));
});
Deno.test("Scraps/explore page", async () => {
const result = await zennApi("scraps/explore");
const {
dailyScraps,
alltimeScraps,
recentScraps,
} = result;
assert(implementsZennScrap(dailyScraps[0]));
assert(implementsZennScrap(alltimeScraps[0]));
assert(implementsZennScrap(recentScraps[0]));
});
Deno.test("Topics page", async () => {
const result = await zennApi("topics");
assert(implementsZennTopic(result.topics[0]));
});
Deno.test("Topics/zenn page", async () => {
const result = await zennApi("topics/zenn");
const {
topic,
articles,
} = result;
assert(implementsZennTopic(topic));
assert(implementsZennArticle(articles[0]));
});
Deno.test("Topics/zenn?tab=books page", async () => {
const result = await zennApi("topics/zenn?tab=books");
const {
topic,
// books,
} = result;
assert(implementsZennTopic(topic));
// assert(implementsZennBook(books[0])); not found in test...
});
// Deno.test("Search page", async () => {
// assert(true);
// });