-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Node } from "../node"; | ||
import SelectNodeHandler from "../selectNodeHandler"; | ||
|
||
describe("getSelectedNodesUnder", () => { | ||
it("returns the nodes when the nodes have an id", () => { | ||
const node = new Node({ id: 1 }); | ||
|
||
const child = new Node({ id: 2 }); | ||
node.addChild(child); | ||
|
||
const nodeMap = new Map<NodeId, Node>(); | ||
nodeMap.set(1, node); | ||
nodeMap.set(2, child); | ||
|
||
const getNodeById = (id: NodeId) => nodeMap.get(id) ?? null; | ||
|
||
const selectNodeHandler = new SelectNodeHandler({ getNodeById }); | ||
selectNodeHandler.addToSelection(child); | ||
|
||
expect( | ||
selectNodeHandler.getSelectedNodesUnder(node), | ||
).toIncludeAllMembers([child]); | ||
}); | ||
}); |