1
1
import Tree from '../../models/tree' ;
2
2
import routes from '../../models/routes' ;
3
- import { ComponentData , Fiber , FiberRoot } from '../../types/backendTypes' ;
3
+ import { ComponentData , Fiber } from '../../types/backendTypes' ;
4
4
import { FunctionComponent , ClassComponent , HostRoot } from '../../types/backendTypes' ;
5
5
import IncrementFunc from './IncrementFunc' ;
6
6
import IncrementClass from './IncrementClass' ;
7
- import { transformSync } from '@babel/core' ;
7
+ import componentActionsRecord from '../../models/masterState' ;
8
+ import deepCopy from './deepCopy' ;
8
9
9
10
// ----------------------------TEST CASES FOR ROOT------------------------------
10
11
export const root : Fiber = {
@@ -60,6 +61,7 @@ const functionalComponentData: ComponentData = {
60
61
state : null ,
61
62
} ;
62
63
64
+ componentActionsRecord . clear ( ) ;
63
65
export const functionalPayload : Tree = new Tree ( 'root' , 'root' ) ;
64
66
functionalPayload . route = rootPayload . route ;
65
67
functionalPayload . addChild ( { count : 0 } , 'IncrementFunc' , functionalComponentData , null ) ;
@@ -101,11 +103,12 @@ const classComponentData: ComponentData = {
101
103
state : { count : 0 } ,
102
104
} ;
103
105
106
+ componentActionsRecord . clear ( ) ;
104
107
export const classPayload = new Tree ( 'root' , 'root' ) ;
105
108
classPayload . route = rootPayload . route ;
106
-
107
109
classPayload . addChild ( { count : 0 } , 'IncrementClass' , classComponentData , null ) ;
108
110
111
+ componentActionsRecord . clear ( ) ;
109
112
export const updateClassPayload = new Tree ( 'root' , 'root' ) ;
110
113
updateClassPayload . route = rootPayload . route ;
111
114
updateClassPayload . addChild (
@@ -116,6 +119,7 @@ updateClassPayload.addChild(
116
119
) ;
117
120
118
121
// -----------------------TEST CASE FOR MIX OF COMPONENTS-----------------------
122
+ componentActionsRecord . clear ( ) ;
119
123
export const mixComponents : Fiber = deepCopy ( root ) ;
120
124
mixComponents . child = deepCopy ( functionalComponent ) ;
121
125
mixComponents . sibling = deepCopy ( classComponent ) ;
@@ -164,18 +168,3 @@ classPayloadMix.componentData = {
164
168
mixPayload . children [ 0 ] . children . push ( deepCopy ( classPayloadMix ) ) ;
165
169
166
170
// console.dir(mixPayload, { depth: null });
167
-
168
- function deepCopy ( obj ) {
169
- if ( obj === null || typeof obj !== 'object' ) {
170
- return obj ;
171
- }
172
- const copy = Array . isArray ( obj ) ? [ ] : { } ;
173
- Object . keys ( obj ) . forEach ( ( key ) => {
174
- if ( typeof obj [ key ] === 'function' ) {
175
- copy [ key ] = obj [ key ] ;
176
- } else {
177
- copy [ key ] = deepCopy ( obj [ key ] ) ;
178
- }
179
- } ) ;
180
- return copy ;
181
- }
0 commit comments