2026-09-05 21:35:07 +03:00
|
|
|
/**
|
|
|
|
|
* Legend/filters predicate tests — the pure half of the graph-view filters
|
|
|
|
|
* panel (isNodeVisible); the sigma reducers just consume its verdict.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import assert from "node:assert/strict";
|
|
|
|
|
import { describe, it } from "node:test";
|
|
|
|
|
import { isNodeVisible } from "../components/graph-view.tsx";
|
|
|
|
|
|
2026-09-08 22:23:07 +03:00
|
|
|
const node = {
|
2026-09-09 00:40:02 +03:00
|
|
|
name: "Money multiplier",
|
|
|
|
|
statement: "The maximum ratio of broad money a bank can create from each unit of base money.",
|
2026-09-08 22:23:07 +03:00
|
|
|
};
|
2026-09-05 21:35:07 +03:00
|
|
|
|
2026-09-09 01:24:08 +03:00
|
|
|
describe("isNodeVisible (search predicate)", () => {
|
|
|
|
|
it("is visible with an empty query", () => {
|
|
|
|
|
assert.equal(isNodeVisible(node, ""), true);
|
2026-09-05 21:35:07 +03:00
|
|
|
});
|
|
|
|
|
|
2026-09-08 22:23:07 +03:00
|
|
|
it("search matches the statement case-insensitively", () => {
|
2026-09-09 01:24:08 +03:00
|
|
|
assert.equal(isNodeVisible(node, "MONEY multiplier"), true);
|
2026-09-05 21:35:07 +03:00
|
|
|
});
|
|
|
|
|
|
2026-09-09 00:40:02 +03:00
|
|
|
it("search matches the statement when the name does not", () => {
|
2026-09-09 01:24:08 +03:00
|
|
|
assert.equal(isNodeVisible(node, "MAXIMUM ratio"), true);
|
|
|
|
|
assert.equal(isNodeVisible(node, " velocity"), false);
|
2026-09-05 21:35:07 +03:00
|
|
|
});
|
|
|
|
|
|
2026-09-09 00:40:02 +03:00
|
|
|
it("search matches the name when the statement does not", () => {
|
2026-09-09 01:24:08 +03:00
|
|
|
assert.equal(isNodeVisible(node, "money MULTIPLIER"), true);
|
|
|
|
|
assert.equal(isNodeVisible(node, " banking"), false);
|
2026-09-09 00:40:02 +03:00
|
|
|
});
|
|
|
|
|
|
2026-09-05 21:35:07 +03:00
|
|
|
it("whitespace-only query is no filter", () => {
|
2026-09-09 01:24:08 +03:00
|
|
|
assert.equal(isNodeVisible(node, " "), true);
|
2026-09-05 21:35:07 +03:00
|
|
|
});
|
|
|
|
|
|
2026-09-09 01:24:08 +03:00
|
|
|
|
2026-09-05 21:35:07 +03:00
|
|
|
});
|