20 lines
947 B
JavaScript
20 lines
947 B
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
|
|
const search = await readFile(new URL("../src/search.js", import.meta.url), "utf8");
|
|
|
|
test("primary platform search page has a timeout", () => {
|
|
const block = search.match(/if \(!config\.preferFallback\) \{[\s\S]*?html = await response\.text\(\);/)?.[0] || "";
|
|
assert.match(block, /signal: fetchSignal\(options\.signal, SEARCH_TIMEOUT_MS\)/);
|
|
});
|
|
|
|
test("search module exposes a bounded quick search timeout", () => {
|
|
assert.match(search, /const SEARCH_TIMEOUT_MS = 6_000/);
|
|
assert.match(search, /const QUICK_SEARCH_TIMEOUT_MS = 6_000/);
|
|
assert.match(search, /export async function findProgramPageQuick/);
|
|
assert.match(search, /controller\.abort\(\)/);
|
|
assert.match(search, /findProgramPage\(platform, keyword, \{ signal: controller\.signal \}\)/);
|
|
assert.match(search, /signal: fetchSignal\(options\.signal/);
|
|
});
|