Skip to content

Commit 3f993fc

Browse files
committed
changed adding children test descriptions of first few
1 parent 22a5f88 commit 3f993fc

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

src/backend/__tests__/tree.test.ts

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Tree from '../tree';
22
import { networkInterfaces } from 'os';
33

44
describe('Tree unit test', () => {
5-
describe('Constructor', () => {
6-
const newTree = new Tree({});
5+
const newTree = new Tree({});
76

7+
describe('Constructor', () => {
88
it('should be able to create a newTree', () => {
99
expect(newTree.state).toEqual({});
1010
});
@@ -31,29 +31,35 @@ describe('Tree unit test', () => {
3131

3232
/**
3333
*
34-
* the tree should have initial values of state, name, etc to be default as per newly created tree
34+
* ^^
35+
* the tree should have initial values of state,
36+
* name, etc to be default as per newly created tree
37+
* update the add child and add sibling tests
3538
*
39+
* update the clean tree copy test to make it test for deep equaltiy? (note:
40+
* this test may always fail if we make it so because there is no way to have deep equalituy
41+
* with some shit that isn't allowed)
3642
*/
3743

3844
describe('Adding children', () => {
39-
let newTree = new Tree({});
40-
let returnChild = newTree.addChild('stateful', 'child', {}, null);
41-
42-
it('should be able to add a child', () => {
43-
expect(typeof newTree.children).toEqual('object');
44-
expect(Array.isArray(newTree.children)).toBeTruthy;
45-
})
45+
const returnChild = newTree.addChild('stateful', 'child', {}, null);
4646

47-
it(`its parent should be newTree`, () => {
47+
it('should have the child be in the children\'s array property', () => {
48+
// check if returnChild is in the children array property of tree that invoked addChild
49+
expect(newTree.children).toContain(returnChild);
50+
});
51+
52+
it('should have the object that invoked it be it\'s parent', () => {
53+
// checking parent to be the tree that invoked addChild
4854
expect(returnChild.parent).toEqual(newTree);
49-
})
55+
});
5056

5157
it('parent now contains an array of children and each children is a valid tree', () => {
5258
expect(newTree.children[0]).toHaveProperty('state');
5359
expect(newTree.children[0]).toHaveProperty('name');
5460
expect(newTree.children[0]).toHaveProperty('componentData');
55-
})
56-
})
61+
});
62+
});
5763

5864
describe('Adding sibling', () => {
5965
let newTree = new Tree({});
@@ -75,27 +81,6 @@ describe('Tree unit test', () => {
7581
})
7682
})
7783

78-
79-
describe('Adding sibling', () => {
80-
let newTree = new Tree({});
81-
let returnChild = newTree.addChild('stateful', 'child', {}, null);
82-
let returnSibling = returnChild.addSibling('stateful', 'child', {}, null);
83-
it('the tree now has 2 children', () => {
84-
expect(newTree.children.length).toBe(2);
85-
})
86-
87-
it('both of the children has the parent as this tree', () => {
88-
expect(newTree.children[0]).toEqual(returnChild);
89-
expect(newTree.children[1]).toEqual(returnSibling);
90-
})
91-
92-
it('both of the children has the parent as this tree', () => {
93-
expect(returnChild.parent).toEqual(newTree);
94-
expect(returnSibling.parent).toEqual(newTree);
95-
})
96-
})
97-
98-
9984
describe('Copy & clean tree', () => {
10085
let newTree = new Tree({});
10186
let returnChild = newTree.addChild('stateful', 'child', {}, null);

0 commit comments

Comments
 (0)