@@ -92,16 +92,49 @@ test('onFetchedProjectData new loads project data into vm', () => {
9292 expect ( resultState . projectData ) . toBe ( '1010101' ) ;
9393} ) ;
9494
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' , ( ) => {
9698 const initialState = {
97- loadingState : LoadingState . LOADING_VM_FILE_UPLOAD
99+ loadingState : LoadingState . LOADING_VM_WITH_ID
98100 } ;
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 ) ;
100131 const resultState = projectStateReducer ( initialState , action ) ;
101132 expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
102133} ) ;
103134
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' , ( ) => {
105138 const initialState = {
106139 loadingState : LoadingState . LOADING_VM_FILE_UPLOAD
107140 } ;
@@ -110,25 +143,38 @@ test('onLoadedProject upload, with canSave true, prepares to save', () => {
110143 expect ( resultState . loadingState ) . toBe ( LoadingState . AUTO_UPDATING ) ;
111144} ) ;
112145
113- test ( 'onLoadedProject with id shows with id' , ( ) => {
146+ test ( 'onLoadedProject (LOADING_VM_FILE_UPLOAD, false, true) shows without id' , ( ) => {
114147 const initialState = {
115- loadingState : LoadingState . LOADING_VM_WITH_ID
148+ loadingState : LoadingState . LOADING_VM_FILE_UPLOAD
116149 } ;
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 ) ;
118161 const resultState = projectStateReducer ( initialState , action ) ;
119162 expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
120163} ) ;
121164
122- test ( 'onLoadedProject new shows without id' , ( ) => {
165+ test ( 'onLoadedProject (LOADING_VM_FILE_UPLOAD, false, false), with no project id, shows without id' , ( ) => {
123166 const initialState = {
124- loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
167+ loadingState : LoadingState . LOADING_VM_FILE_UPLOAD ,
168+ projectId : null
125169 } ;
126- const action = onLoadedProject ( initialState . loadingState , false , true ) ;
170+ const action = onLoadedProject ( initialState . loadingState , false , false ) ;
127171 const resultState = projectStateReducer ( initialState , action ) ;
128172 expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
129173} ) ;
130174
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' , ( ) => {
132178 const initialState = {
133179 loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
134180 } ;
@@ -137,26 +183,26 @@ test('onLoadedProject new, to save shows without id', () => {
137183 expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
138184} ) ;
139185
140- test ( 'onLoadedProject with success false, no project id, shows without id' , ( ) => {
186+ test ( 'onLoadedProject (LOADING_VM_NEW_DEFAULT, false, true) shows without id' , ( ) => {
141187 const initialState = {
142- loadingState : LoadingState . LOADING_VM_WITH_ID ,
143- projectId : null
188+ loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
144189 } ;
145- const action = onLoadedProject ( initialState . loadingState , false , false ) ;
190+ const action = onLoadedProject ( initialState . loadingState , false , true ) ;
146191 const resultState = projectStateReducer ( initialState , action ) ;
147192 expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITHOUT_ID ) ;
148193} ) ;
149194
150- test ( 'onLoadedProject with success false, valid project id, shows with id ' , ( ) => {
195+ test ( 'onLoadedProject (LOADING_VM_NEW_DEFAULT, false, false) shows error ' , ( ) => {
151196 const initialState = {
152- loadingState : LoadingState . LOADING_VM_WITH_ID ,
153- projectId : '12345'
197+ loadingState : LoadingState . LOADING_VM_NEW_DEFAULT
154198 } ;
155199 const action = onLoadedProject ( initialState . loadingState , false , false ) ;
156200 const resultState = projectStateReducer ( initialState , action ) ;
157- expect ( resultState . loadingState ) . toBe ( LoadingState . SHOWING_WITH_ID ) ;
201+ expect ( resultState . loadingState ) . toBe ( LoadingState . ERROR ) ;
158202} ) ;
159203
204+ // doneUpdatingProject
205+
160206test ( 'doneUpdatingProject with id shows with id' , ( ) => {
161207 const initialState = {
162208 loadingState : LoadingState . MANUAL_UPDATING
0 commit comments