Skip to content

Commit b9889e4

Browse files
committed
mainReducer.test passing
1 parent e7643b9 commit b9889e4

File tree

1 file changed

+119
-3
lines changed

1 file changed

+119
-3
lines changed

src/app/__tests__/mainReducer.test.jsx

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('mainReducer testing', () => {
1212
state = {
1313
tabs: {
1414
87: {
15+
initialSnapshot: [],
1516
snapshots: [1, 2, 3, 4],
1617
sliderIndex: 2,
1718
viewIndex: -1,
@@ -23,10 +24,67 @@ describe('mainReducer testing', () => {
2324
intervalId: 87,
2425
playing: true,
2526
index: 3,
26-
hierarchy: null, // should be a linked list with four nodes
27-
currLocation: null, // should point to the last node in hierarchy
27+
initialHierarchy: null,
28+
// should be a linked list with four nodes
29+
hierarchy: {
30+
index: 0,
31+
name: 1,
32+
branch: 0,
33+
stateSnapshot: {
34+
state: {},
35+
children: [{
36+
state: { test: 'test' },
37+
name: 'App',
38+
componentData: { actualDuration: 3.5 },
39+
}],
40+
},
41+
children: [{
42+
index: 1,
43+
name: 2,
44+
branch: 0,
45+
stateSnapshot: {
46+
state: {},
47+
children: [{
48+
state: { test: 'test' },
49+
name: 'App',
50+
componentData: { actualDuration: 3.5 },
51+
}],
52+
},
53+
children: [{
54+
index: 2,
55+
name: 3,
56+
branch: 0,
57+
stateSnapshot: {
58+
state: {},
59+
children: [{
60+
state: { test: 'test' },
61+
name: 'App',
62+
componentData: { actualDuration: 3.5 },
63+
}],
64+
},
65+
children: [{
66+
index: 3,
67+
name: 4,
68+
branch: 0,
69+
stateSnapshot: {
70+
state: {},
71+
children: [{
72+
state: { test: 'test' },
73+
name: 'App',
74+
componentData: { actualDuration: 3.5 },
75+
}],
76+
},
77+
children: [],
78+
}],
79+
}],
80+
}],
81+
},
82+
// currLocation: null,
83+
// should point to the last node in hierarchy
84+
currLocation: 4,
2885
},
2986
75: {
87+
initialSnapshot: [],
3088
snapshots: [1, 2, 3, 4],
3189
sliderIndex: 3,
3290
viewIndex: -1,
@@ -37,6 +95,64 @@ describe('mainReducer testing', () => {
3795
},
3896
intervalId: 75,
3997
playing: false,
98+
initialHierarchy: null,
99+
// should be a linked list with four nodes
100+
hierarchy: {
101+
index: 0,
102+
name: 1,
103+
branch: 0,
104+
stateSnapshot: {
105+
state: {},
106+
children: [{
107+
state: { test: 'test' },
108+
name: 'App',
109+
componentData: { actualDuration: 3.5 },
110+
}],
111+
},
112+
children: [{
113+
index: 1,
114+
name: 2,
115+
branch: 0,
116+
stateSnapshot: {
117+
state: {},
118+
children: [{
119+
state: { test: 'test' },
120+
name: 'App',
121+
componentData: { actualDuration: 3.5 },
122+
}],
123+
},
124+
children: [{
125+
index: 2,
126+
name: 3,
127+
branch: 0,
128+
stateSnapshot: {
129+
state: {},
130+
children: [{
131+
state: { test: 'test' },
132+
name: 'App',
133+
componentData: { actualDuration: 3.5 },
134+
}],
135+
},
136+
children: [{
137+
index: 3,
138+
name: 4,
139+
branch: 0,
140+
stateSnapshot: {
141+
state: {},
142+
children: [{
143+
state: { test: 'test' },
144+
name: 'App',
145+
componentData: { actualDuration: 3.5 },
146+
}],
147+
},
148+
children: [],
149+
}],
150+
}],
151+
}],
152+
},
153+
// currLocation: null,
154+
// should point to the last node in hierarchy
155+
currLocation: 4,
40156
},
41157
},
42158
currentTab: 87,
@@ -100,7 +216,7 @@ describe('mainReducer testing', () => {
100216
expect(mainReducer(state, emptySnapshots()).tabs[currentTab].viewIndex).toEqual(-1);
101217
expect(mainReducer(state, emptySnapshots()).tabs[currentTab].playing).toEqual(false);
102218
expect(mainReducer(state, emptySnapshots()).tabs[currentTab]
103-
.snapshots).toEqual(state.tabs[currentTab].snapshots.slice(0, 1));
219+
.snapshots).toEqual([state.tabs[currentTab].snapshots[state.tabs[currentTab].snapshots.length - 1]]);
104220
});
105221
// should push slider back to start position
106222
});

0 commit comments

Comments
 (0)