@@ -303,6 +303,38 @@ describe('Contentstack apps test', () => {
303
303
done ( )
304
304
} )
305
305
} )
306
+ it ( 'should reinstall the app' , done => {
307
+ const mock = new MockAdapter ( Axios )
308
+ const uid = appMock . uid
309
+ // using same installation mock data for reinstall
310
+ mock . onPut ( `/manifests/${ uid } /reinstall` ) . reply ( 200 , {
311
+ data : {
312
+ ...installationMock
313
+ }
314
+ } )
315
+ const targetUid = 'target_uid'
316
+ const targetType = 'target_type'
317
+ makeApp ( { data : { uid } } )
318
+ . upgrade ( { targetUid, targetType } )
319
+ . then ( ( reinstallation ) => {
320
+ expect ( reinstallation . status ) . to . be . equal ( installationMock . status )
321
+ expect ( reinstallation . manifest . name ) . to . be . equal ( installationMock . manifest . name )
322
+ expect ( reinstallation . target . uid ) . to . be . equal ( installationMock . target . uid )
323
+ expect ( reinstallation . organization_uid ) . to . be . equal ( installationMock . organization_uid )
324
+ expect ( reinstallation . uid ) . to . be . equal ( installationMock . uid )
325
+ } )
326
+ . catch ( done )
327
+
328
+ // failing test when empty data is passed
329
+ mock . onPut ( `/manifests/${ uid } /reinstall` ) . reply ( 400 , { } )
330
+ makeApp ( { data : { uid } } )
331
+ . upgrade ( { targetUid, targetType } )
332
+ . then ( )
333
+ . catch ( ( error ) => {
334
+ expect ( error ) . to . not . equal ( null )
335
+ done ( )
336
+ } )
337
+ } )
306
338
} )
307
339
308
340
function checkApp ( app ) {
0 commit comments