@@ -3,7 +3,7 @@ import { State, Action } from '../app/src/interfaces/InterfacesNew';
3
3
4
4
import initialState from '../app/src/context/initialState' ;
5
5
6
- describe ( 'Testing componentReducer functionality' , function ( ) {
6
+ describe ( 'Testing componentReducer functionality' , ( ) => {
7
7
let state : State = initialState ;
8
8
9
9
// TEST 'ADD COMPONENT'
@@ -12,18 +12,18 @@ describe('Testing componentReducer functionality', function () {
12
12
const action : Action = {
13
13
type : 'ADD COMPONENT' ,
14
14
payload : {
15
- componentName : " TestRegular" ,
16
- root : false
17
- }
18
- }
15
+ componentName : ' TestRegular' ,
16
+ root : false ,
17
+ } ,
18
+ } ;
19
19
state = reducer ( state , action ) ;
20
20
// expect state.components array to have length 2
21
21
const length = state . components . length ;
22
22
expect ( length ) . toEqual ( 2 ) ;
23
23
// expect new component name to match name of last elem in state.components array
24
24
expect ( state . components [ length - 1 ] . name ) . toEqual ( action . payload . componentName ) ;
25
- } )
26
- } )
25
+ } ) ;
26
+ } ) ;
27
27
28
28
// TEST 'ADD CHILD'
29
29
describe ( 'ADD CHILD reducer' , ( ) => {
@@ -33,9 +33,9 @@ describe('Testing componentReducer functionality', function () {
33
33
payload : {
34
34
type : 'Component' ,
35
35
typeId : 2 ,
36
- childId : null
37
- }
38
- }
36
+ childId : null ,
37
+ } ,
38
+ } ;
39
39
// switch focus to very first root component
40
40
state . canvasFocus = { componentId : 1 , childId : null } ;
41
41
state = reducer ( state , action ) ;
@@ -49,8 +49,8 @@ describe('Testing componentReducer functionality', function () {
49
49
const addedChild = state . components . find ( comp => comp . id === newParent . children [ 1 ] . typeId ) ;
50
50
// expect new child typeId to correspond to component with name 'TestRegular'
51
51
expect ( addedChild . name ) . toEqual ( 'TestRegular' ) ;
52
- } )
53
- } )
52
+ } ) ;
53
+ } ) ;
54
54
55
55
// TEST 'CHANGE POSITION'
56
56
describe ( 'CHANGE POSITION reducer ' , ( ) => {
@@ -60,43 +60,43 @@ describe('Testing componentReducer functionality', function () {
60
60
payload : {
61
61
type : 'HTML Element' ,
62
62
typeId : 9 ,
63
- childId : null
64
- }
65
- }
63
+ childId : null ,
64
+ } ,
65
+ } ;
66
66
state = reducer ( state , actionHtml ) ;
67
67
const actionChangePos : Action = {
68
68
type : 'CHANGE POSITION' ,
69
69
payload : {
70
70
currentChildId : 1 ,
71
- newParentChildId : null
72
- }
73
- }
71
+ newParentChildId : null ,
72
+ } ,
73
+ } ;
74
74
state = reducer ( state , actionChangePos ) ;
75
75
const changeParent = state . components . find ( comp => comp . id === state . canvasFocus . componentId ) ;
76
76
const changeParentChildLength = changeParent . children . length ;
77
77
// expect last child of parent to be moved Component element
78
- expect ( changeParent . children [ changeParentChildLength - 1 ] . type ) . toEqual ( 'Component' ) ;
78
+ expect ( changeParent . children [ changeParentChildLength - 1 ] . type ) . toEqual ( 'Component' ) ;
79
79
// expect last child of parent to have current child ID of payload
80
- expect ( changeParent . children [ changeParentChildLength - 1 ] . childId ) . toEqual ( 1 ) ;
81
- } )
82
- } )
80
+ expect ( changeParent . children [ changeParentChildLength - 1 ] . childId ) . toEqual ( 1 ) ;
81
+ } ) ;
82
+ } ) ;
83
83
84
84
// TEST 'DELETE CHILD'
85
85
describe ( 'DELETE CHILD reducer' , ( ) => {
86
86
it ( 'should delete child of focused top-level component' , ( ) => {
87
87
// canvas still focused on childId: 2, which is an HTML element
88
88
const action : Action = {
89
- type : 'DELETE CHILD'
90
- }
89
+ type : 'DELETE CHILD' ,
90
+ } ;
91
91
state = reducer ( state , action ) ;
92
92
// expect only one remaining child
93
93
const delParent = state . components . find ( comp => comp . id === state . canvasFocus . componentId ) ;
94
94
// expect remaining child to have type 'Component' and to be preceded by separator
95
95
expect ( delParent . children . length ) . toEqual ( 2 ) ;
96
- expect ( delParent . children [ delParent . children . length - 1 ] . type ) . toEqual ( 'Component' ) ;
97
- expect ( delParent . children [ delParent . children . length - 2 ] . name ) . toEqual ( 'separator' ) ;
98
- } )
99
- } )
96
+ expect ( delParent . children [ delParent . children . length - 1 ] . type ) . toEqual ( 'Component' ) ;
97
+ expect ( delParent . children [ delParent . children . length - 2 ] . name ) . toEqual ( 'separator' ) ;
98
+ } ) ;
99
+ } ) ;
100
100
101
101
// TEST 'CHANGE FOCUS'
102
102
describe ( 'CHANGE FOCUS reducer' , ( ) => {
@@ -105,14 +105,14 @@ describe('Testing componentReducer functionality', function () {
105
105
type : 'CHANGE FOCUS' ,
106
106
payload : {
107
107
componentId : 2 ,
108
- childId : null
109
- }
110
- }
108
+ childId : null ,
109
+ } ,
110
+ } ;
111
111
state = reducer ( state , action ) ;
112
112
expect ( state . canvasFocus . componentId ) . toEqual ( 2 ) ;
113
113
expect ( state . canvasFocus . childId ) . toEqual ( null ) ;
114
- } )
115
- } )
114
+ } ) ;
115
+ } ) ;
116
116
117
117
// TEST 'UPDATE CSS'
118
118
describe ( 'UPDATE CSS reducer' , ( ) => {
@@ -121,59 +121,58 @@ describe('Testing componentReducer functionality', function () {
121
121
type : 'UPDATE CSS' ,
122
122
payload : {
123
123
style : {
124
- backgroundColor : 'gray'
125
- }
126
- }
127
- }
124
+ backgroundColor : 'gray' ,
125
+ } ,
126
+ } ,
127
+ } ;
128
128
state = reducer ( state , action ) ;
129
129
const styledComp = state . components . find ( comp => comp . id === state . canvasFocus . componentId ) ;
130
130
// expect the style property on targeted comp to equal style property in payload
131
131
expect ( styledComp . style . backgroundColor ) . toEqual ( action . payload . style . backgroundColor ) ;
132
- } )
133
- } )
132
+ } ) ;
133
+ } ) ;
134
134
135
135
// TEST 'UPDATE PROJECT NAME'
136
136
describe ( 'UPDATE PROJECT NAME reducer' , ( ) => {
137
137
it ( 'should update project with specified name' , ( ) => {
138
138
const action : Action = {
139
139
type : 'UPDATE PROJECT NAME' ,
140
- payload : 'TESTNAME'
141
- }
140
+ payload : 'TESTNAME' ,
141
+ } ;
142
142
state = reducer ( state , action ) ;
143
143
// expect state name to equal payload
144
144
expect ( state . name ) . toEqual ( action . payload ) ;
145
- } )
146
- } )
145
+ } ) ;
146
+ } ) ;
147
147
148
148
// TEST 'CHANGE PROJECT TYPE'
149
149
describe ( 'CHANGE PROJECT TYPE reducer' , ( ) => {
150
150
it ( 'should change project type to specified type' , ( ) => {
151
151
const action : Action = {
152
152
type : 'CHANGE PROJECT TYPE' ,
153
153
payload : {
154
- projectType : 'Classic React'
155
- }
154
+ projectType : 'Classic React' ,
155
+ } ,
156
156
} ;
157
157
state = reducer ( state , action ) ;
158
158
expect ( state . projectType ) . toEqual ( action . payload . projectType ) ;
159
- } )
160
- } )
159
+ } ) ;
160
+ } ) ;
161
161
162
162
// TEST 'RESET STATE'
163
163
describe ( 'RESET STATE reducer' , ( ) => {
164
164
it ( 'should reset project to initial state' , ( ) => {
165
165
const action : Action = {
166
166
type : 'RESET STATE' ,
167
- payload : ''
168
- }
167
+ payload : '' ,
168
+ } ;
169
169
state = reducer ( state , action ) ;
170
170
// expect default project to have empty string as name
171
171
expect ( state . name ) . toEqual ( 'TESTNAME' ) ;
172
172
// expect default project to only have one component in components array
173
173
expect ( state . components . length ) . toEqual ( 1 ) ;
174
174
// expect lone component to have no children :(
175
175
expect ( state . components [ 0 ] . children . length ) . toEqual ( 0 ) ;
176
- } )
177
- } )
178
-
179
- } )
176
+ } ) ;
177
+ } ) ;
178
+ } ) ;
0 commit comments