@@ -54,6 +54,13 @@ describe('Testing componentReducer functionality', function () {
54
54
} )
55
55
} )
56
56
57
+ // TEST 'DELETE CHILD'
58
+ describe ( 'DELETE CHILD reducer' , ( ) => {
59
+ it ( 'should delete child of focused top-level component' , ( ) => {
60
+ console . log ( 'state before delete child ' , state ) ;
61
+ } )
62
+ } )
63
+
57
64
// TEST 'CHANGE FOCUS'
58
65
describe ( 'CHANGE FOCUS reducer' , ( ) => {
59
66
it ( 'should change focus to specified component' , ( ) => {
@@ -74,11 +81,61 @@ describe('Testing componentReducer functionality', function () {
74
81
75
82
// TEST 'UPDATE CSS'
76
83
describe ( 'UPDATE CSS reducer' , ( ) => {
77
- it ( 'should update background color of focused component' , ( ) => {
78
-
84
+ it ( 'should add style to focused component' , ( ) => {
85
+ const action = {
86
+ type : 'UPDATE CSS' ,
87
+ payload : {
88
+ style : {
89
+ backgroundColor : 'gray'
90
+ }
91
+ }
92
+ }
93
+ state = reducer ( state , action ) ;
94
+ const styledComp = state . components . find ( comp => comp . id === state . canvasFocus . componentId ) ;
95
+ // expect the style property on targeted comp to equal style property in payload
96
+ expect ( styledComp . style . backgroundColor ) . toEqual ( action . payload . style . backgroundColor ) ;
97
+ } )
98
+ } )
99
+
100
+ // TEST 'UPDATE PROJECT NAME'
101
+ describe ( 'UPDATE PROJECT NAME reducer' , ( ) => {
102
+ it ( 'should update project with specified name' , ( ) => {
103
+ const action = {
104
+ type : 'UPDATE PROJECT NAME' ,
105
+ payload : 'TESTNAME'
106
+ }
107
+ state = reducer ( state , action ) ;
108
+ // expect state name to equal payload
109
+ expect ( state . name ) . toEqual ( action . payload ) ;
110
+ } )
111
+ } )
112
+
113
+ // TEST 'CHANGE PROJECT TYPE'
114
+ describe ( 'CHANGE PROJECT TYPE reducer' , ( ) => {
115
+ it ( 'should change project type to specified type' , ( ) => {
116
+ const action = {
117
+ type : 'CHANGE PROJECT TYPE' ,
118
+ payload : {
119
+ projectType : 'Classic React'
120
+ }
121
+ } ;
122
+ state = reducer ( state , action ) ;
123
+ expect ( state . projectType ) . toEqual ( action . payload . projectType ) ;
79
124
} )
80
125
} )
81
126
82
127
// TEST 'RESET STATE'
128
+ describe ( 'RESET STATE reducer' , ( ) => {
129
+ it ( 'should reset project to initial state' , ( ) => {
130
+ const action = {
131
+ type : 'RESET STATE'
132
+ }
133
+ state = reducer ( state , action ) ;
134
+ // expect default project to have empty string as name
135
+ expect ( state . name ) . toEqual ( '' ) ;
136
+ // expect default project to only have one component in components array
137
+ expect ( state . components . length ) . toEqual ( 1 ) ;
138
+ } )
139
+ } )
83
140
84
141
} )
0 commit comments