-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
60 lines (45 loc) · 1.28 KB
/
test.js
File metadata and controls
60 lines (45 loc) · 1.28 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
/**
SIMPLE TEST SCRIPT
node test.js
or
bun test.js
*/
import {
search,
fetchContent,
checkBinaryStatus,
getPlatformTarget
} from "./packages/quack-search/dist/index.js";
console.log("=== Environment ===");
console.log("Platform target:", getPlatformTarget());
// Optional: diagnostic only (should NOT gate execution)
console.log("\n=== Binary Status (pre-run) ===");
const statusBefore = checkBinaryStatus();
console.log(JSON.stringify(statusBefore, null, 2));
console.log("\n=== Search Test (auto-bootstrap) ===");
try {
const results = await search("adistrim", { maxResults: 3 });
for (const r of results) {
console.log(r.title, r.url);
}
} catch (err) {
console.error("Search failed:", err);
process.exit(1);
}
// Binary should now exist (either npm, cache, or override)
console.log("\n=== Binary Status (post-run) ===");
const statusAfter = checkBinaryStatus();
console.log(JSON.stringify(statusAfter, null, 2));
console.log("\n=== Fetch Test ===");
try {
const page = await fetchContent("https://adistrim.in/now");
if (!page.success) {
console.log("Blocked:", page.reason);
} else {
console.log(page.text.slice(0, 500));
}
} catch (err) {
console.error("Fetch failed:", err);
process.exit(1);
}
console.log("\nAll tests completed successfully");