@@ -92,16 +92,49 @@ test('onFetchedProjectData new loads project data into vm', () => {
92
92
expect ( resultState . projectData ) . toBe ( '1010101' ) ;
93
93
} ) ;
94
94
95
- test ( 'onLoadedProject upload, with canSave false, shows without id' , ( ) => {
95
+ // onLoadedProject: LOADING_VM_WITH_ID
96
+
97
+ test ( 'onLoadedProject (LOADING_VM_WITH_ID, true, true) shows with id' , ( ) => {
96
98
const initialState = {
97
- loadingState : LoadingState . LOADING_VM_FILE_UPLOAD
99
+ loadingState : LoadingState . LOADING_VM_WITH_ID
98
100
} ;
99
- const action = onLoadedProject ( initialState . loadingState , false , true ) ;
101
+ const action = onLoadedProject ( initialState . loadingState , true , true ) ;
102
+ const resultState = projectStateReducer ( initialState , action ) ;
103
+ expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
104
+ } ) ;
105
+
106
+ test ( 'onLoadedProject (LOADING_VM_WITH_ID, false, true) shows with id' , ( ) => {
107
+ const initialState = {
108
+ loadingState : LoadingState . LOADING_VM_WITH_ID
109
+ } ;
110
+ const action = onLoadedProject ( initialState . loadingState , true , true ) ;
111
+ const resultState = projectStateReducer ( initialState , action ) ;
112
+ expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
113
+ } ) ;
114
+
115
+ test ( 'onLoadedProject (LOADING_VM_WITH_ID, false, false), with project id, shows with id' , ( ) => {
116
+ const initialState = {
117
+ loadingState : LoadingState . LOADING_VM_WITH_ID ,
118
+ projectId : '12345'
119
+ } ;
120
+ const action = onLoadedProject ( initialState . loadingState , false , false ) ;
121
+ const resultState = projectStateReducer ( initialState , action ) ;
122
+ expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
123
+ } ) ;
124
+
125
+ test ( 'onLoadedProject (LOADING_VM_WITH_ID, false, false), with no project id, shows without id' , ( ) => {
126
+ const initialState = {
127
+ loadingState : LoadingState . LOADING_VM_WITH_ID ,
128
+ projectId : null
129
+ } ;
130
+ const action = onLoadedProject ( initialState . loadingState , false , false ) ;
100
131
const resultState = projectStateReducer ( initialState , action ) ;
101
132
expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
102
133
} ) ;
103
134
104
- test ( 'onLoadedProject upload, with canSave true, prepares to save' , ( ) => {
135
+ // onLoadedProject: LOADING_VM_FILE_UPLOAD
136
+
137
+ test ( 'onLoadedProject(LOADING_VM_FILE_UPLOAD, true, true) prepares to save' , ( ) => {
105
138
const initialState = {
106
139
loadingState : LoadingState . LOADING_VM_FILE_UPLOAD
107
140
} ;
@@ -110,25 +143,38 @@ test('onLoadedProject upload, with canSave true, prepares to save', () => {
110
143
expect ( resultState . loadingState ) . toBe ( LoadingState . AUTO_UPDATING ) ;
111
144
} ) ;
112
145
113
- test ( 'onLoadedProject with id shows with id' , ( ) => {
146
+ test ( 'onLoadedProject (LOADING_VM_FILE_UPLOAD, false, true) shows without id' , ( ) => {
114
147
const initialState = {
115
- loadingState : LoadingState . LOADING_VM_WITH_ID
148
+ loadingState : LoadingState . LOADING_VM_FILE_UPLOAD
116
149
} ;
117
- const action = onLoadedProject ( initialState . loadingState , true , true ) ;
150
+ const action = onLoadedProject ( initialState . loadingState , false , true ) ;
151
+ const resultState = projectStateReducer ( initialState , action ) ;
152
+ expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
153
+ } ) ;
154
+
155
+ test ( 'onLoadedProject (LOADING_VM_FILE_UPLOAD, false, false), with project id, shows with id' , ( ) => {
156
+ const initialState = {
157
+ loadingState : LoadingState . LOADING_VM_FILE_UPLOAD ,
158
+ projectId : '12345'
159
+ } ;
160
+ const action = onLoadedProject ( initialState . loadingState , false , false ) ;
118
161
const resultState = projectStateReducer ( initialState , action ) ;
119
162
expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
120
163
} ) ;
121
164
122
- test ( 'onLoadedProject new shows without id' , ( ) => {
165
+ test ( 'onLoadedProject (LOADING_VM_FILE_UPLOAD, false, false), with no project id, shows without id' , ( ) => {
123
166
const initialState = {
124
- loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
167
+ loadingState : LoadingState . LOADING_VM_FILE_UPLOAD ,
168
+ projectId : null
125
169
} ;
126
- const action = onLoadedProject ( initialState . loadingState , false , true ) ;
170
+ const action = onLoadedProject ( initialState . loadingState , false , false ) ;
127
171
const resultState = projectStateReducer ( initialState , action ) ;
128
172
expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
129
173
} ) ;
130
174
131
- test ( 'onLoadedProject new, to save shows without id' , ( ) => {
175
+ // onLoadedProject: LOADING_VM_NEW_DEFAULT
176
+
177
+ test ( 'onLoadedProject (LOADING_VM_NEW_DEFAULT, true, true) shows without id' , ( ) => {
132
178
const initialState = {
133
179
loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
134
180
} ;
@@ -137,26 +183,26 @@ test('onLoadedProject new, to save shows without id', () => {
137
183
expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
138
184
} ) ;
139
185
140
- test ( 'onLoadedProject with success false, no project id, shows without id' , ( ) => {
186
+ test ( 'onLoadedProject (LOADING_VM_NEW_DEFAULT, false, true) shows without id' , ( ) => {
141
187
const initialState = {
142
- loadingState : LoadingState . LOADING_VM_WITH_ID ,
143
- projectId : null
188
+ loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
144
189
} ;
145
- const action = onLoadedProject ( initialState . loadingState , false , false ) ;
190
+ const action = onLoadedProject ( initialState . loadingState , false , true ) ;
146
191
const resultState = projectStateReducer ( initialState , action ) ;
147
192
expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
148
193
} ) ;
149
194
150
- test ( 'onLoadedProject with success false, valid project id, shows with id ' , ( ) => {
195
+ test ( 'onLoadedProject (LOADING_VM_NEW_DEFAULT, false, false) shows error ' , ( ) => {
151
196
const initialState = {
152
- loadingState : LoadingState . LOADING_VM_WITH_ID ,
153
- projectId : '12345'
197
+ loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
154
198
} ;
155
199
const action = onLoadedProject ( initialState . loadingState , false , false ) ;
156
200
const resultState = projectStateReducer ( initialState , action ) ;
157
- expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
201
+ expect ( resultState . loadingState ) . toBe ( LoadingState . ERROR ) ;
158
202
} ) ;
159
203
204
+ // doneUpdatingProject
205
+
160
206
test ( 'doneUpdatingProject with id shows with id' , ( ) => {
161
207
const initialState = {
162
208
loadingState : LoadingState . MANUAL_UPDATING
0 commit comments