Files
learnharness/tests/graph-view-filters.test.ts
T

39 lines
1.2 KiB
TypeScript
Raw Normal View History

/**
* 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";
const node = {
name: "Money multiplier",
statement: "The maximum ratio of broad money a bank can create from each unit of base money.",
};
describe("isNodeVisible (search predicate)", () => {
it("is visible with an empty query", () => {
assert.equal(isNodeVisible(node, ""), true);
});
it("search matches the statement case-insensitively", () => {
assert.equal(isNodeVisible(node, "MONEY multiplier"), true);
});
it("search matches the statement when the name does not", () => {
assert.equal(isNodeVisible(node, "MAXIMUM ratio"), true);
assert.equal(isNodeVisible(node, " velocity"), false);
});
it("search matches the name when the statement does not", () => {
assert.equal(isNodeVisible(node, "money MULTIPLIER"), true);
assert.equal(isNodeVisible(node, " banking"), false);
});
it("whitespace-only query is no filter", () => {
assert.equal(isNodeVisible(node, " "), true);
});
});