Files
WebHooker/tests/filter-node.test.ts
T
翅膀 84fc63663e feat(console): confirm removing filled editor rows
Filter conditions and groups, delivery targets, saved fragments and forge
hosts vanished on a single click, taking whatever had been typed with
them. Rows holding content now ask first, while empty, never-filled
rows (`isBlankNode`: default operator, no path, no values, not negated)
are still removed directly.
2026-10-17 00:58:24 +08:00

28 lines
1.1 KiB
TypeScript

import { describe, it, expect } from "bun:test";
import { blankNode, isBlankNode } from "../app/composables/useFilterNode";
describe("isBlankNode", () => {
it("treats untouched conditions and groups as blank", () => {
expect(isBlankNode(blankNode("leaf"))).toBe(true);
expect(isBlankNode(blankNode("all"))).toBe(true);
expect(isBlankNode(blankNode("not"))).toBe(true);
});
it("treats any value, path or negation as content", () => {
const withValue = blankNode("all");
withValue.children[0]!.leaf.values = ["push"];
expect(isBlankNode(withValue)).toBe(false);
const negated = blankNode("leaf");
negated.leaf.exclude = true;
expect(isBlankNode(negated)).toBe(false);
const withPath = blankNode("leaf");
withPath.leaf.path = "sender.login";
expect(isBlankNode(withPath)).toBe(false);
// `exists` is a complete condition without any value.
const exists = blankNode("all");
exists.children[0]!.leaf.type = "branch";
exists.children[0]!.leaf.op = "exists";
expect(isBlankNode(exists)).toBe(false);
});
});