diff --git a/src/test/elementTree.test.ts b/src/test/elementTree.test.ts index 328ede1..d2db6d9 100644 --- a/src/test/elementTree.test.ts +++ b/src/test/elementTree.test.ts @@ -113,6 +113,14 @@ describe("elementTree — holding", () => { expect(holding(beside, Trash2)).toEqual([]); }); + it("never calls a component of the tree: a holder its child renders is not there", () => { + const Child = vi.fn(() => h("button", { id: "inside" }, h(Trash2))); + const node = h("div", { id: "d" }, h(Child)); + expect(holding(node, Trash2)).toEqual([]); + expect(ids(holding(node, Child))).toEqual(["d"]); + expect(Child).not.toHaveBeenCalled(); + }); + it("lets a fragment hold its own children, not its parent", () => { const node = h("div", { id: "d" }, h(Fragment, null, h(Trash2))); const holders = holding(node, Trash2); diff --git a/src/test/elementTree.ts b/src/test/elementTree.ts index 6a517ba..fe4c378 100644 --- a/src/test/elementTree.ts +++ b/src/test/elementTree.ts @@ -2,8 +2,9 @@ // // A test that calls a component as a plain function, under the shared hook // harness of this folder or without it, gets back a tree of React elements, -// not a DOM. These two helpers search that tree; before #467, test files kept -// their own copy. Each semantic below is proved by elementTree.test.ts. +// not a DOM. These two helpers search that tree, shared since #467 (several +// test files still keep a copy of their own). Each semantic below is proved by +// elementTree.test.ts. // // - `find(node, pred)`: every element of the tree for which `pred` is true, // depth first: an element before what it holds, siblings in order, and an