-
Notifications
You must be signed in to change notification settings - Fork 0
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
17 changed files
with
115 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ node_modules | |
.parcel-cache | ||
dist | ||
.idea | ||
.vscode | ||
.DS_Store | ||
storybook-static | ||
.tsbuildinfo | ||
|
This file was deleted.
Oops, something went wrong.
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
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
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,78 @@ | ||
import { ITree, Tree } from "./Tree"; | ||
|
||
|
||
describe('Tree', () => { | ||
const createChildData = () => ({ | ||
iterate: jest.fn(), | ||
} as ITree) | ||
test('Creation of a Tree object', () => { | ||
const tree = new Tree(createChildData()); | ||
expect(tree).toBeInstanceOf(Tree); | ||
}); | ||
|
||
test('Adding and removing child elements', () => { | ||
const parent = new Tree(createChildData()); | ||
const child1 = new Tree(createChildData()); | ||
const child2 = new Tree(createChildData()); | ||
|
||
parent.append(child1); | ||
parent.append(child2); | ||
|
||
expect(parent.children.has(child1)).toBe(true); | ||
expect(parent.children.has(child2)).toBe(true); | ||
|
||
parent.remove(child1); | ||
parent.remove(child2); | ||
|
||
expect(parent.children.size).toBe(0); | ||
}); | ||
|
||
test('Changing the rendering order', () => { | ||
const parent = new Tree(createChildData()); | ||
const child1 = new Tree(createChildData()); | ||
const child2 = new Tree(createChildData()); | ||
|
||
parent.append(child1); | ||
parent.append(child2); | ||
|
||
child1.renderOrder = 1; | ||
child2.renderOrder = 2; | ||
|
||
expect(child1.renderOrder).toBe(1); | ||
expect(child2.renderOrder).toBe(2); | ||
}); | ||
|
||
test('Changing the z-index', () => { | ||
const parent = new Tree(createChildData()); | ||
const child1 = new Tree(createChildData()); | ||
const child2 = new Tree(createChildData()); | ||
|
||
parent.append(child1); | ||
parent.append(child2); | ||
|
||
child1.zIndex = 1; | ||
child2.zIndex = 2; | ||
|
||
expect(child1.zIndex).toBe(1); | ||
expect(child2.zIndex).toBe(2); | ||
}); | ||
|
||
test('Traversing the tree', () => { | ||
const root = new Tree(createChildData()); | ||
const child1 = new Tree(createChildData()); | ||
const child2 = new Tree(createChildData()); | ||
|
||
root.append(child1); | ||
root.append(child2); | ||
|
||
let count = 0; | ||
|
||
root.traverseDown((node) => { | ||
count++; | ||
expect(node).toBeInstanceOf(Tree); | ||
return true; | ||
}); | ||
|
||
expect(count).toBe(3); // Including the root | ||
}); | ||
}); |
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
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