test: the sub-view census reads each source once
Read three times, the scan ran past the 5 s test timeout when the gate loaded the machine.
This commit is contained in:
@@ -423,12 +423,14 @@ describe("module URL keys", () => {
|
||||
});
|
||||
const named = new Set(["MODE_URL", "PLEX_SUB_URL"]);
|
||||
const unnamed = (text: string) => handed(text).filter((arg) => !named.has(arg));
|
||||
// Each source read once: read three times, the scan ran past the test timeout under a loaded gate.
|
||||
const files = sources(SRC).filter(
|
||||
(f) => !relative(SRC, f).split("\\").join("/").startsWith("lib/history"),
|
||||
);
|
||||
expect(files.flatMap((f) => unnamed(readFileSync(f, "utf8")))).toEqual([]);
|
||||
const texts = files.map((f) => readFileSync(f, "utf8"));
|
||||
expect(texts.flatMap(unnamed)).toEqual([]);
|
||||
// The call sites are seen (a scan of none would pass)…
|
||||
expect(new Set(files.flatMap((f) => handed(readFileSync(f, "utf8"))))).toEqual(named);
|
||||
expect(new Set(texts.flatMap(handed))).toEqual(named);
|
||||
// …and the check tells an inline definition from a named one.
|
||||
expect(unnamed('useHistorySubview(sub, { key: "zz", encode, decode })')).toEqual([
|
||||
'{ key: "zz", encode, decode }',
|
||||
@@ -442,7 +444,7 @@ describe("module URL keys", () => {
|
||||
]);
|
||||
// Under another name it is a call no scan sees.
|
||||
const aliased = (text: string) => /\buseHistorySubview\s+as\b/.test(text);
|
||||
expect(files.filter((f) => aliased(readFileSync(f, "utf8")))).toEqual([]);
|
||||
expect(files.filter((_f, i) => aliased(texts[i]!))).toEqual([]);
|
||||
expect(aliased('import { useHistorySubview as useSub } from "./history";')).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user