-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
107 lines (107 loc) · 3.85 KB
/
test.js
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
import test from "ava";
import { githubApiGetProject, githubApiGetLogin, getGithubTopics } from "./githubApiGet.js";
import { GITHUB_PROJECT_TOPICS, GITHUB_LOGIN_AVATAR_URL } from "./consts.js";
// dummy tests
test("foo", (t) => {
t.pass();
});
test("bar", async (t) => {
const bar = Promise.resolve("bar");
t.is(await bar, "bar");
});
// tests for new githubApiGetProject
test("mockdataTopicsWithPathExpression", async (t) => {
const loginName = "roebi";
const projectName = "01-01-vanilla-HTML5-starter-page";
const infoLog = true;
const isProd = false;
const githubTopics = githubApiGetProject(loginName, projectName, GITHUB_PROJECT_TOPICS, infoLog, isProd);
t.deepEqual(await githubTopics, [" mockdata!", "html5", "html5-template", "roebi", "starter"]);
});
test("mockdataProjectInfoEmpty", async (t) => {
const loginName = "roebi";
const projectName = "01-01-vanilla-HTML5-starter-page";
const infoLog = true;
const isProd = false;
const githubProjectInfoEmtpy = githubApiGetProject("", "", "", infoLog, isProd);
t.deepEqual(await githubProjectInfoEmtpy, {});
});
test("realdataTopicsWithPathExpression", async (t) => {
const loginName = "roebi";
const projectName = "01-01-vanilla-HTML5-starter-page";
const infoLog = true;
const isProd = true;
const githubTopics = githubApiGetProject(loginName, projectName, GITHUB_PROJECT_TOPICS, infoLog, isProd);
t.deepEqual(await githubTopics, [
"css3",
"html5",
"html5-template",
"roebi",
"starter",
"template",
"template-project",
]);
});
// tests for new githubApiGetLogin
test("mockdataLoginInfoWithPathExpression", async (t) => {
const loginName = "roebi";
const infoLog = true;
const isProd = false;
const githubLoginInfoWithPathExpression = githubApiGetLogin(loginName, GITHUB_LOGIN_AVATAR_URL, infoLog, isProd);
t.deepEqual(await githubLoginInfoWithPathExpression, ["https://avatars.githubusercontent.com/u/3611826?v=4"]);
});
test("mockdataLoginInfoEmpty", async (t) => {
const loginName = "";
const infoLog = true;
const isProd = false;
const githubLoginInfoEmtpy = githubApiGetLogin(loginName, "", infoLog, isProd);
t.deepEqual(await githubLoginInfoEmtpy, {});
});
test("realdataLoginInfoWithPathExpression", async (t) => {
const loginName = "roebi";
const infoLog = true;
const isProd = true;
const githubLoginInfoWithPathExpression = githubApiGetLogin(loginName, GITHUB_LOGIN_AVATAR_URL, infoLog, isProd);
t.deepEqual(await githubLoginInfoWithPathExpression, ["https://avatars.githubusercontent.com/u/3611826?v=4"]);
});
// tests for deprecated getGithubTopics
test("mockdataTopics", async (t) => {
const loginName = "roebi";
const projectName = "01-01-vanilla-HTML5-starter-page";
const infoLog = true;
const isProd = false;
const githubTopics = getGithubTopics(loginName, projectName, infoLog, isProd);
t.deepEqual(await githubTopics, [" mockdata!", "html5", "html5-template", "roebi", "starter"]);
});
test("noTopics", async (t) => {
const loginName = "";
const projectName = "";
const infoLog = true;
const isProd = false;
const githubTopics = getGithubTopics(loginName, projectName, infoLog, isProd);
t.deepEqual(await githubTopics, []);
});
test("prodDataTopics", async (t) => {
const loginName = "roebi";
const projectName = "01-01-vanilla-HTML5-starter-page";
const infoLog = true;
const isProd = true;
const githubTopics = getGithubTopics(loginName, projectName, infoLog, isProd);
t.deepEqual(await githubTopics, [
"css3",
"html5",
"html5-template",
"roebi",
"starter",
"template",
"template-project",
]);
});
test("prodDataNoTopicsInvalidProjectName", async (t) => {
const loginName = "roebi";
const projectName = "project-not-exist";
const infoLog = true;
const isProd = true;
const githubTopics = getGithubTopics(loginName, projectName, infoLog, isProd);
t.deepEqual(await githubTopics, []);
});