@@ -308,16 +308,38 @@ describe('Unit: Commands > Install', function () {
308
308
const InstallCommand = proxyquire ( modulePath , {
309
309
'../utils/version' : { resolveVersion, versionFromZip}
310
310
} ) ;
311
+ const log = sinon . stub ( ) ;
312
+
313
+ const testInstance = new InstallCommand ( { } , { } ) ;
314
+ const context = { argv : { zip : '/some/zip/file.zip' } , ui : { log} } ;
315
+
316
+ await testInstance . version ( context ) ;
317
+ expect ( resolveVersion . called ) . to . be . false ;
318
+ expect ( versionFromZip . calledOnce ) . to . be . true ;
319
+ expect ( versionFromZip . calledWith ( '/some/zip/file.zip' ) ) . to . be . true ;
320
+ expect ( context . version ) . to . equal ( '1.5.2' ) ;
321
+ expect ( context . installPath ) . to . equal ( path . join ( process . cwd ( ) , 'versions/1.5.2' ) ) ;
322
+ expect ( log . called ) . to . be . false ;
323
+ } ) ;
324
+
325
+ it ( 'logs if both version and zip are passed' , async function ( ) {
326
+ const resolveVersion = sinon . stub ( ) . resolves ( '1.5.0' ) ;
327
+ const versionFromZip = sinon . stub ( ) . resolves ( '1.5.2' ) ;
328
+ const InstallCommand = proxyquire ( modulePath , {
329
+ '../utils/version' : { resolveVersion, versionFromZip}
330
+ } ) ;
331
+ const log = sinon . stub ( ) ;
311
332
312
333
const testInstance = new InstallCommand ( { } , { } ) ;
313
- const context = { argv : { version : '1.0.0' , zip : '/some/zip/file.zip' } } ;
334
+ const context = { argv : { version : '1.0.0' , zip : '/some/zip/file.zip' } , ui : { log } } ;
314
335
315
336
await testInstance . version ( context ) ;
316
337
expect ( resolveVersion . called ) . to . be . false ;
317
338
expect ( versionFromZip . calledOnce ) . to . be . true ;
318
339
expect ( versionFromZip . calledWith ( '/some/zip/file.zip' ) ) . to . be . true ;
319
340
expect ( context . version ) . to . equal ( '1.5.2' ) ;
320
341
expect ( context . installPath ) . to . equal ( path . join ( process . cwd ( ) , 'versions/1.5.2' ) ) ;
342
+ expect ( log . calledOnce ) . to . be . true ;
321
343
} ) ;
322
344
} ) ;
323
345
0 commit comments