-
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.
* Add test for NodeElement * Change parameter to HtmlElement * Add test
- Loading branch information
Showing
5 changed files
with
63 additions
and
18 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
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,22 @@ | ||
import BorderDropHint from "../../nodeElement/borderDropHint"; | ||
|
||
it("creates an element", () => { | ||
const element = document.createElement("div"); | ||
|
||
const jqTreeElement = document.createElement("div"); | ||
jqTreeElement.classList.add("jqtree-element"); | ||
element.append(jqTreeElement); | ||
|
||
new BorderDropHint(element, 0); | ||
|
||
expect(jqTreeElement.children.length).toBe(1); | ||
expect(jqTreeElement.children[0]).toHaveClass("jqtree-border"); | ||
}); | ||
|
||
it("doesn't create an element if the node doesn't have a jqtree-element child", () => { | ||
const element = document.createElement("div"); | ||
|
||
new BorderDropHint(element, 0); | ||
|
||
expect(element.children).toBeEmpty(); | ||
}); |
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,29 @@ | ||
import { Node } from "../../node"; | ||
import NodeElement from "../../nodeElement"; | ||
|
||
it("sets the element to the element of the node", () => { | ||
const treeElement = document.createElement("div"); | ||
document.body.append(treeElement); | ||
|
||
const element = document.createElement("div"); | ||
document.body.append(element); | ||
|
||
const node = new Node(); | ||
node.element = element; | ||
|
||
const getScrollLeft = () => 0; | ||
|
||
const nodeElement = new NodeElement({ getScrollLeft, node, treeElement }); | ||
expect(nodeElement.element).toEqual(element); | ||
}); | ||
|
||
it("sets the element to the tree element when the node doesn't have an element", () => { | ||
const treeElement = document.createElement("div"); | ||
document.body.append(treeElement); | ||
|
||
const node = new Node(); | ||
const getScrollLeft = () => 0; | ||
|
||
const nodeElement = new NodeElement({ getScrollLeft, node, treeElement }); | ||
expect(nodeElement.element).toEqual(treeElement); | ||
}); |
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