Skip to content

Commit 3527ae8

Browse files
authored
Merge pull request #5 from oslabs-beta/james/test/tree-files
James/test/tree files
2 parents 945f4ca + d1a99f2 commit 3527ae8

File tree

6 files changed

+987
-58
lines changed

6 files changed

+987
-58
lines changed

src/backend/__tests__/helpers.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ describe('AST Unit Tests', () => {
5454
});
5555
});
5656

57+
58+
59+
// test notes
5760
describe('getHooksNames', () => {
5861
it('Should return object with one getter/setter for a single useState instance', () => {
5962
const elementType = `function SingleUseFakeComponent() {

src/backend/__tests__/timeJump.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ describe('unit testing for timeJump.ts', () => {
6565
timeJump = timeJumpRequire(mode);
6666
});
6767
test('calling the initial require should return a function', () => {
68-
expect(typeof timeJumpRequire).toBe('function');
68+
const funcDef = timeJumpRequire;
69+
expect(typeof funcDef).toBe('function');
6970
});
7071

7172
// xdescribe('testing iteration through snapshot tree', () => {

src/backend/__tests__/tree.test.ts

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,98 @@
11
import Tree from '../tree';
2-
import { networkInterfaces } from 'os';
32

43
describe('Tree unit test', () => {
5-
describe('Constructor', () => {
6-
let newTree = new Tree({});
4+
const newTree = new Tree({});
75

6+
describe('Constructor', () => {
87
it('should be able to create a newTree', () => {
98
expect(newTree.state).toEqual({});
10-
})
9+
});
1110

12-
it('should have 5 properties', () => {
11+
it('should have 8 properties', () => {
1312
expect(newTree).toHaveProperty('state');
1413
expect(newTree).toHaveProperty('name');
1514
expect(newTree).toHaveProperty('componentData');
1615
expect(newTree).toHaveProperty('children');
1716
expect(newTree).toHaveProperty('parent');
18-
})
17+
expect(newTree).toHaveProperty('isExpanded');
18+
expect(newTree).toHaveProperty('rtid');
19+
expect(newTree).toHaveProperty('route');
20+
});
1921

2022
it('has name default value as stateless', () => {
2123
expect(newTree.name).toBe('nameless');
22-
})
24+
});
2325

2426
it('has children as an empty array', () => {
2527
expect(newTree.children).toEqual([]);
26-
})
27-
})
28-
28+
});
29+
});
30+
31+
/**
32+
*
33+
* making sure to adhere to ts practices when goign through tests
34+
*
35+
* ^^
36+
* the tree should have initial values of state,
37+
* name, etc to be default as per newly created tree
38+
* update the add child and add sibling tests
39+
*
40+
* update the clean tree copy test to make it test for deep equaltiy? (note:
41+
* this test may always fail if we make it so because there is no way to have deep equalituy
42+
* with some shit that isn't allowed)
43+
*/
2944

3045
describe('Adding children', () => {
31-
let newTree = new Tree({});
32-
let returnChild = newTree.addChild('stateful', 'child', {}, null);
33-
34-
it('should be able to add a child', () => {
35-
expect(typeof newTree.children).toEqual('object');
36-
expect(Array.isArray(newTree.children)).toBeTruthy;
37-
})
38-
39-
it(`its parent should be newTree`, () => {
46+
const returnChild = newTree.addChild('stateful', 'child', {}, null);
47+
48+
it('should have the child be in the children\'s array property', () => {
49+
// check if returnChild is in the children array property of tree that invoked addChild
50+
expect(newTree.children).toContain(returnChild);
51+
});
52+
53+
it('should have the object that invoked it be it\'s parent', () => {
54+
// checking parent to be the tree that invoked addChild
4055
expect(returnChild.parent).toEqual(newTree);
41-
})
56+
});
4257

4358
it('parent now contains an array of children and each children is a valid tree', () => {
4459
expect(newTree.children[0]).toHaveProperty('state');
4560
expect(newTree.children[0]).toHaveProperty('name');
4661
expect(newTree.children[0]).toHaveProperty('componentData');
47-
})
48-
})
62+
});
63+
});
4964

5065
describe('Adding sibling', () => {
51-
let newTree = new Tree({});
52-
let returnChild = newTree.addChild('stateful', 'child', {}, null);
53-
let returnSibling = returnChild.addSibling('stateful', 'child', {}, null);
54-
55-
it('the tree now has 2 children', () => {
56-
expect(newTree.children.length).toBe(2);
57-
})
58-
59-
it('both of the children has the parent as this tree', () => {
60-
expect(newTree.children[0]).toEqual(returnChild);
61-
expect(newTree.children[1]).toEqual(returnSibling);
62-
})
66+
// const newTree = new Tree({});
67+
const returnChild = newTree.addChild('stateful', 'child', {}, null);
68+
const returnSibling = returnChild.addSibling('stateful', 'child', {}, null);
6369

64-
it('both of the children has the parent as this tree', () => {
65-
expect(returnChild.parent).toEqual(newTree);
66-
expect(returnSibling.parent).toEqual(newTree);
67-
})
68-
})
69-
70-
71-
describe('Adding sibling', () => {
72-
let newTree = new Tree({});
73-
let returnChild = newTree.addChild('stateful', 'child', {}, null);
74-
let returnSibling = returnChild.addSibling('stateful', 'child', {}, null);
7570
it('the tree now has 2 children', () => {
7671
expect(newTree.children.length).toBe(2);
77-
})
72+
});
7873

7974
it('both of the children has the parent as this tree', () => {
8075
expect(newTree.children[0]).toEqual(returnChild);
8176
expect(newTree.children[1]).toEqual(returnSibling);
82-
})
77+
});
8378

8479
it('both of the children has the parent as this tree', () => {
8580
expect(returnChild.parent).toEqual(newTree);
8681
expect(returnSibling.parent).toEqual(newTree);
87-
})
88-
})
82+
});
83+
});
8984

85+
// review this test
86+
// returnSibling not used?
87+
// Check Test
9088

9189
describe('Copy & clean tree', () => {
92-
let newTree = new Tree({});
93-
let returnChild = newTree.addChild('stateful', 'child', {}, null);
94-
let returnSibling = returnChild.addSibling('stateful', 'child', {}, null);
95-
let copy = newTree.cleanTreeCopy();
90+
// const newTree = new Tree({});
91+
const returnChild = newTree.addChild('stateful', 'child', {}, null);
92+
returnChild.addSibling('stateful', 'child', {}, null);
93+
const copy = newTree.cleanTreeCopy();
9694
it('its copy has 2 children', () => {
9795
expect(copy.children.length).toEqual(2);
98-
})
99-
})
100-
})
96+
});
97+
});
98+
});

src/backend/linkFiber.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ function createTree(
200200
// }
201201

202202
// check to see if we can get the information we were looking for
203+
// need to figure out what tag is
203204
if (tag === 5) {
204205
try {
205206
if (memoizedProps.children && memoizedProps.children[0]?._owner?.memoizedProps !== undefined) {

src/backend/timeJump.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import routes from './routes';
1717
*/
1818

1919
/* eslint-disable no-param-reassign */
20-
2120
import componentActionsRecord from './masterState';
2221

2322
const circularComponentTable = new Set();

0 commit comments

Comments
 (0)