-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.js
More file actions
74 lines (66 loc) · 2.21 KB
/
Copy pathtest.js
File metadata and controls
74 lines (66 loc) · 2.21 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
/*
* ======= • ======= • ======= • ======= • =======• =======
* MiruroAPI — test.js
* Repository: https://github.com/Shineii86/MiruroAPI
*
* @description
* Integration test suite for MiruroAPI endpoints.
* Tests all major endpoints for correct response format.
*
* @author Shinei Nouzen
* @license MIT
* ======= • ======= • ======= • ======= • =======• =======
*/
const BASE = process.env.API_URL || "https://mirurotvapi.vercel.app/api";
const tests = [
{ name: "Health", url: "/health" },
{ name: "Stats", url: "/stats" },
{ name: "OpenAPI", url: "/openapi" },
{ name: "Search", url: "/search?query=naruto" },
{ name: "Suggestions", url: "/suggestions?query=naruto" },
{ name: "Filter", url: "/filter?genre=Action&per_page=1" },
{ name: "Trending", url: "/trending?per_page=1" },
{ name: "Popular", url: "/popular?per_page=1" },
{ name: "Upcoming", url: "/upcoming?per_page=1" },
{ name: "Recent", url: "/recent?per_page=1" },
{ name: "Spotlight", url: "/spotlight" },
{ name: "Schedule", url: "/schedule" },
{ name: "Info", url: "/info/20" },
{ name: "Characters", url: "/anime/20/characters" },
{ name: "Relations", url: "/anime/20/relations" },
{ name: "Recommendations", url: "/anime/20/recommendations" },
{ name: "Episodes", url: "/episodes/20" },
{ name: "Watch", url: "/watch/kiwi/20/sub/animepahe-1" },
];
let passed = 0;
let failed = 0;
async function runTest(test) {
try {
const res = await fetch(`${BASE}${test.url}`);
if (!res.ok) {
console.log(`❌ ${test.name} - HTTP ${res.status}`);
failed++;
return;
}
const data = await res.json();
if (data.success === true && data.results) {
console.log(`✅ ${test.name}`);
passed++;
} else {
console.log(`❌ ${test.name} - Invalid response format`);
failed++;
}
} catch (error) {
console.log(`❌ ${test.name} - ${error.message}`);
failed++;
}
}
async function runAll() {
console.log(`\n🧪 Running ${tests.length} tests...\n`);
for (const test of tests) {
await runTest(test);
}
console.log(`\n📊 Results: ${passed} passed, ${failed} failed, ${tests.length} total\n`);
process.exit(failed > 0 ? 1 : 0);
}
runAll();