test: prove that holding never calls a component either (#467)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m53s
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m53s
Self-review: the docblock says that neither helper calls a component of the tree, but only find had a test for it. holding gets its own (a holder that a child component renders is not found, the component is never called). The header no longer reads as if no test file kept a copy of its own: several still do. Resolves #467 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cecaca910b
commit
483f886ac0
2 changed files with 11 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue