@@ -6,10 +6,11 @@ import { expect } from 'chai'
66
77dotenv . config ( )
88
9- // var stacks = {}
10- var orgID = process . env . ORGANIZATION
11- var client = { }
12- var appUid = ''
9+ let stack = { }
10+ const orgID = process . env . ORGANIZATION
11+ let client = { }
12+ let appUid = ''
13+ let installationUid = ''
1314const app = {
1415 name : 'My New App' ,
1516 description : 'My new test app' ,
@@ -21,6 +22,7 @@ describe('Apps api Test', () => {
2122 setup ( ( ) => {
2223 const user = jsonReader ( 'loggedinuser.json' )
2324 client = contentstackClient ( user . authtoken )
25+ stack = jsonReader ( 'stack.json' )
2426 } )
2527
2628 it ( 'Fetch all apps test' , done => {
@@ -101,9 +103,46 @@ describe('Apps api Test', () => {
101103 . catch ( done )
102104 } )
103105
106+ it ( 'Install app test' , done => {
107+ client . organization ( orgID ) . app ( appUid ) . install ( { targetType : 'stack' , targetUid : stack . api_key } )
108+ . then ( ( installation ) => {
109+ installationUid = installation . uid
110+ expect ( installation . uid ) . to . not . equal ( undefined )
111+ expect ( installation . params . organization_uid ) . to . be . equal ( orgID )
112+ expect ( installation . urlPath ) . to . be . equal ( `/installations/${ installation . uid } ` )
113+ expect ( installation . fetch ) . to . not . equal ( undefined )
114+ expect ( installation . update ) . to . not . equal ( undefined )
115+ expect ( installation . uninstall ) . to . not . equal ( undefined )
116+ done ( )
117+ } )
118+ . catch ( done )
119+ } )
120+
121+ it ( 'Fetch installation test' , done => {
122+ client . organization ( orgID ) . app ( appUid ) . installation ( installationUid ) . fetch ( )
123+ . then ( ( installation ) => {
124+ expect ( installation . uid ) . to . be . equal ( installationUid )
125+ expect ( installation . params . organization_uid ) . to . be . equal ( orgID )
126+ expect ( installation . urlPath ) . to . be . equal ( `/installations/${ installation . uid } ` )
127+ expect ( installation . target . type ) . to . be . equal ( 'stack' )
128+ expect ( installation . target . uid ) . to . be . equal ( stack . api_key )
129+ expect ( installation . status ) . to . be . equal ( 'installed' )
130+ done ( )
131+ } ) . catch ( done )
132+ } )
133+
134+ it ( 'Uninstall installation test' , done => {
135+ client . organization ( orgID ) . app ( appUid ) . installation ( installationUid ) . uninstall ( )
136+ . then ( ( installation ) => {
137+ expect ( installation ) . to . deep . equal ( { } )
138+ done ( )
139+ } ) . catch ( done )
140+ } )
141+
104142 it ( 'Delete app test' , done => {
105143 client . organization ( orgID ) . app ( appUid ) . delete ( )
106144 . then ( ( appResponse ) => {
145+ expect ( appResponse ) . to . deep . equal ( { } )
107146 done ( )
108147 } )
109148 . catch ( done )
0 commit comments