@@ -23,6 +23,10 @@ describe(commands.FILE_UNARCHIVE, () => {
2323 let confirmationPromptStub : sinon . SinonStub ;
2424 let loggerLogSpy : sinon . SinonSpy ;
2525
26+ const unarchiveResponse = {
27+ value : 'reactivating'
28+ } ;
29+
2630 before ( ( ) => {
2731 sinon . stub ( auth , 'restoreAuth' ) . resolves ( ) ;
2832 sinon . stub ( telemetry , 'trackEvent' ) . resolves ( ) ;
@@ -134,7 +138,7 @@ describe(commands.FILE_UNARCHIVE, () => {
134138
135139 it ( 'prompts before unarchiving file when confirmation argument not passed' , async ( ) => {
136140 sinon . stub ( request , 'get' ) . resolves ( { ListId : 'b2307a39-e878-458b-bc90-03bc578531d6' , ListItemAllFields : { Id : 1 } } ) ;
137- sinon . stub ( request , 'post' ) . resolves ( ) ;
141+ sinon . stub ( request , 'post' ) . resolves ( unarchiveResponse ) ;
138142
139143 await command . action ( logger , {
140144 options : {
@@ -147,7 +151,7 @@ describe(commands.FILE_UNARCHIVE, () => {
147151
148152 it ( 'aborts unarchiving file when prompt not confirmed' , async ( ) => {
149153 const getStub = sinon . stub ( request , 'get' ) . resolves ( { ListId : 'b2307a39-e878-458b-bc90-03bc578531d6' , ListItemAllFields : { Id : 1 } } ) ;
150- const postStub = sinon . stub ( request , 'post' ) . resolves ( ) ;
154+ const postStub = sinon . stub ( request , 'post' ) . resolves ( unarchiveResponse ) ;
151155
152156 await command . action ( logger , {
153157 options : {
@@ -176,7 +180,7 @@ describe(commands.FILE_UNARCHIVE, () => {
176180
177181 const postStub = sinon . stub ( request , 'post' ) . callsFake ( async ( opts ) => {
178182 if ( opts . url === `https://contoso.sharepoint.com/sites/test/_api/Lists(guid'b2307a39-e878-458b-bc90-03bc578531d6')/items(1)/UnArchive` ) {
179- return ;
183+ return unarchiveResponse ;
180184 }
181185
182186 throw 'Invalid request' ;
@@ -191,6 +195,7 @@ describe(commands.FILE_UNARCHIVE, () => {
191195 } ) ;
192196
193197 assert ( postStub . calledOnce ) ;
198+ assert ( loggerLogSpy . calledWith ( unarchiveResponse ) ) ;
194199 } ) ;
195200
196201 it ( 'unarchives file by id' , async ( ) => {
@@ -210,7 +215,7 @@ describe(commands.FILE_UNARCHIVE, () => {
210215
211216 const postStub = sinon . stub ( request , 'post' ) . callsFake ( async ( opts ) => {
212217 if ( opts . url === `https://contoso.sharepoint.com/sites/test/_api/Lists(guid'b2307a39-e878-458b-bc90-03bc578531d6')/items(1)/UnArchive` ) {
213- return ;
218+ return unarchiveResponse ;
214219 }
215220
216221 throw 'Invalid request' ;
@@ -226,6 +231,7 @@ describe(commands.FILE_UNARCHIVE, () => {
226231 } ) ;
227232
228233 assert ( postStub . calledOnce ) ;
234+ assert ( loggerLogSpy . calledWith ( unarchiveResponse ) ) ;
229235 } ) ;
230236
231237 it ( 'unarchives file using site-relative url' , async ( ) => {
@@ -244,7 +250,7 @@ describe(commands.FILE_UNARCHIVE, () => {
244250
245251 const postStub = sinon . stub ( request , 'post' ) . callsFake ( async ( opts ) => {
246252 if ( opts . url === `https://contoso.sharepoint.com/sites/test/_api/Lists(guid'b2307a39-e878-458b-bc90-03bc578531d6')/items(1)/UnArchive` ) {
247- return ;
253+ return unarchiveResponse ;
248254 }
249255
250256 throw 'Invalid request' ;
@@ -259,11 +265,12 @@ describe(commands.FILE_UNARCHIVE, () => {
259265 } ) ;
260266
261267 assert ( postStub . calledOnce ) ;
268+ assert ( loggerLogSpy . calledWith ( unarchiveResponse ) ) ;
262269 } ) ;
263270
264- it ( 'outputs no result when unarchiving a file' , async ( ) => {
271+ it ( 'outputs the API response when unarchiving a file' , async ( ) => {
265272 sinon . stub ( request , 'get' ) . resolves ( { ListId : 'b2307a39-e878-458b-bc90-03bc578531d6' , ListItemAllFields : { Id : 1 } } ) ;
266- sinon . stub ( request , 'post' ) . resolves ( ) ;
273+ sinon . stub ( request , 'post' ) . resolves ( unarchiveResponse ) ;
267274
268275 await command . action ( logger , {
269276 options : {
@@ -273,7 +280,7 @@ describe(commands.FILE_UNARCHIVE, () => {
273280 }
274281 } ) ;
275282
276- assert ( loggerLogSpy . notCalled ) ;
283+ assert ( loggerLogSpy . calledOnceWith ( unarchiveResponse ) ) ;
277284 } ) ;
278285
279286 it ( 'handles error correctly' , async ( ) => {
0 commit comments