-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
37 lines (34 loc) · 965 Bytes
/
test.js
File metadata and controls
37 lines (34 loc) · 965 Bytes
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
const { NekosAPI } = require("./v4/NekosAPI");
const v4 = new NekosAPI();
const argv = process.argv.slice(2);
(async () => {
if (argv[0] === "--all" || argv[0] === "-A") {
return Promise.all([
v4.getRandomImage(),
v4.getImage(),
v4.getImages(undefined, { limit: 1 }),
v4.getImageByID("4394")
])
}
return v4.getRandomImage("Catgirl");
})()
.catch(err => {
console.log(err);
testFailed();
})
.then((v4res) => {
if (v4res) {
for (const res of Array.isArray(v4res) ? v4res : [v4res]) {
console.log("Response: v4 image ids:", {
v4: res.id || "Array",
})
}
return console.log("Test finished.");
}
else {
return testFailed(v4res);
}
});
function testFailed(v4res = null) {
throw new Error(`Test failed. ${"v4: " + v4res}`);
}