11import Tree from '../../models/tree' ;
22import routes from '../../models/routes' ;
3- import { ComponentData , Fiber , FiberRoot } from '../../types/backendTypes' ;
3+ import { ComponentData , Fiber } from '../../types/backendTypes' ;
44import { FunctionComponent , ClassComponent , HostRoot } from '../../types/backendTypes' ;
55import IncrementFunc from './IncrementFunc' ;
66import IncrementClass from './IncrementClass' ;
7- import { transformSync } from '@babel/core' ;
7+ import componentActionsRecord from '../../models/masterState' ;
8+ import deepCopy from './deepCopy' ;
89
910// ----------------------------TEST CASES FOR ROOT------------------------------
1011export const root : Fiber = {
@@ -60,6 +61,7 @@ const functionalComponentData: ComponentData = {
6061 state : null ,
6162} ;
6263
64+ componentActionsRecord . clear ( ) ;
6365export const functionalPayload : Tree = new Tree ( 'root' , 'root' ) ;
6466functionalPayload . route = rootPayload . route ;
6567functionalPayload . addChild ( { count : 0 } , 'IncrementFunc' , functionalComponentData , null ) ;
@@ -101,11 +103,12 @@ const classComponentData: ComponentData = {
101103 state : { count : 0 } ,
102104} ;
103105
106+ componentActionsRecord . clear ( ) ;
104107export const classPayload = new Tree ( 'root' , 'root' ) ;
105108classPayload . route = rootPayload . route ;
106-
107109classPayload . addChild ( { count : 0 } , 'IncrementClass' , classComponentData , null ) ;
108110
111+ componentActionsRecord . clear ( ) ;
109112export const updateClassPayload = new Tree ( 'root' , 'root' ) ;
110113updateClassPayload . route = rootPayload . route ;
111114updateClassPayload . addChild (
@@ -116,6 +119,7 @@ updateClassPayload.addChild(
116119) ;
117120
118121// -----------------------TEST CASE FOR MIX OF COMPONENTS-----------------------
122+ componentActionsRecord . clear ( ) ;
119123export const mixComponents : Fiber = deepCopy ( root ) ;
120124mixComponents . child = deepCopy ( functionalComponent ) ;
121125mixComponents . sibling = deepCopy ( classComponent ) ;
@@ -164,18 +168,3 @@ classPayloadMix.componentData = {
164168mixPayload . children [ 0 ] . children . push ( deepCopy ( classPayloadMix ) ) ;
165169
166170// 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