@@ -283,9 +283,11 @@ describe('Unit: Command', function () {
283
283
} ) ;
284
284
285
285
it ( 'loads system and ui dependencies, calls run method' , async function ( ) {
286
- const uiStub = sinon . stub ( ) . returns ( { ui : true } ) ;
286
+ const run = sinon . stub ( ) . callsFake ( fn => fn ( ) ) ;
287
+ const uiStub = sinon . stub ( ) . returns ( { ui : true , run} ) ;
287
288
const setEnvironmentStub = sinon . stub ( ) ;
288
- const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub } ) ;
289
+ const loadOsInfo = sinon . stub ( ) . resolves ( ) ;
290
+ const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub , loadOsInfo} ) ;
289
291
290
292
const Command = proxyquire ( modulePath , {
291
293
'./ui' : uiStub ,
@@ -312,15 +314,19 @@ describe('Unit: Command', function () {
312
314
expect ( setEnvironmentStub . calledOnce ) . to . be . true ;
313
315
expect ( setEnvironmentStub . calledWithExactly ( true , true ) ) . to . be . true ;
314
316
expect ( systemStub . calledOnce ) . to . be . true ;
315
- expect ( systemStub . calledWithExactly ( { ui : true } , [ { extensiona : true } ] ) ) . to . be . true ;
317
+ expect ( systemStub . calledWithExactly ( { ui : true , run} , [ { extensiona : true } ] ) ) . to . be . true ;
318
+ expect ( run . calledOnce ) . to . be . true ;
319
+ expect ( loadOsInfo . calledOnce ) . to . be . true ;
316
320
expect ( runStub . calledOnce ) . to . be . true ;
317
321
expect ( runStub . calledWithExactly ( { verbose : true , prompt : true , development : true , auto : false } ) ) . to . be . true ;
318
322
} ) ;
319
323
320
324
it ( 'binds cleanup handler if cleanup method is defined' , async function ( ) {
321
- const uiStub = sinon . stub ( ) . returns ( { ui : true } ) ;
325
+ const run = sinon . stub ( ) . callsFake ( fn => fn ( ) ) ;
326
+ const uiStub = sinon . stub ( ) . returns ( { ui : true , run} ) ;
322
327
const setEnvironmentStub = sinon . stub ( ) ;
323
- const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub } ) ;
328
+ const loadOsInfo = sinon . stub ( ) . resolves ( ) ;
329
+ const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub , loadOsInfo} ) ;
324
330
325
331
const Command = proxyquire ( modulePath , {
326
332
'./ui' : uiStub ,
@@ -351,7 +357,9 @@ describe('Unit: Command', function () {
351
357
expect ( setEnvironmentStub . calledOnce ) . to . be . true ;
352
358
expect ( setEnvironmentStub . calledWithExactly ( true , true ) ) . to . be . true ;
353
359
expect ( systemStub . calledOnce ) . to . be . true ;
354
- expect ( systemStub . calledWithExactly ( { ui : true } , [ { extensiona : true } ] ) ) . to . be . true ;
360
+ expect ( systemStub . calledWithExactly ( { ui : true , run} , [ { extensiona : true } ] ) ) . to . be . true ;
361
+ expect ( run . calledOnce ) . to . be . true ;
362
+ expect ( loadOsInfo . calledOnce ) . to . be . true ;
355
363
expect ( runStub . calledOnce ) . to . be . true ;
356
364
expect ( runStub . calledWithExactly ( { verbose : false , prompt : false , development : false , auto : true } ) ) . to . be . true ;
357
365
expect ( onStub . calledTwice ) . to . be . true ;
@@ -360,9 +368,11 @@ describe('Unit: Command', function () {
360
368
} ) ;
361
369
362
370
it ( 'runs updateCheck if checkVersion property is true on command class' , async function ( ) {
363
- const uiStub = sinon . stub ( ) . returns ( { ui : true } ) ;
371
+ const run = sinon . stub ( ) . callsFake ( fn => fn ( ) ) ;
372
+ const uiStub = sinon . stub ( ) . returns ( { ui : true , run} ) ;
364
373
const setEnvironmentStub = sinon . stub ( ) ;
365
- const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub } ) ;
374
+ const loadOsInfo = sinon . stub ( ) . resolves ( ) ;
375
+ const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub , loadOsInfo} ) ;
366
376
const preChecksStub = sinon . stub ( ) . resolves ( ) ;
367
377
368
378
const Command = proxyquire ( modulePath , {
@@ -393,18 +403,22 @@ describe('Unit: Command', function () {
393
403
expect ( setEnvironmentStub . calledOnce ) . to . be . true ;
394
404
expect ( setEnvironmentStub . calledWithExactly ( true , true ) ) . to . be . true ;
395
405
expect ( systemStub . calledOnce ) . to . be . true ;
396
- expect ( systemStub . calledWithExactly ( { ui : true } , [ { extensiona : true } ] ) ) . to . be . true ;
406
+ expect ( systemStub . calledWithExactly ( { ui : true , run} , [ { extensiona : true } ] ) ) . to . be . true ;
407
+ expect ( run . calledOnce ) . to . be . true ;
408
+ expect ( loadOsInfo . calledOnce ) . to . be . true ;
397
409
expect ( preChecksStub . calledOnce ) . to . be . true ;
398
- expect ( preChecksStub . calledWithExactly ( { ui : true } , { setEnvironment : setEnvironmentStub } ) ) . to . be . true ;
410
+ expect ( preChecksStub . calledWithExactly ( { ui : true , run } , { setEnvironment : setEnvironmentStub , loadOsInfo } ) ) . to . be . true ;
399
411
expect ( runStub . calledOnce ) . to . be . true ;
400
412
expect ( runStub . calledWithExactly ( { verbose : false , prompt : false , development : false , auto : false } ) ) . to . be . true ;
401
413
} ) ;
402
414
403
415
it ( 'catches errors, passes them to ui error method, then exits' , async function ( ) {
416
+ const run = sinon . stub ( ) . callsFake ( fn => fn ( ) ) ;
404
417
const errorStub = sinon . stub ( ) ;
405
- const uiStub = sinon . stub ( ) . returns ( { error : errorStub } ) ;
418
+ const uiStub = sinon . stub ( ) . returns ( { error : errorStub , run} ) ;
419
+ const loadOsInfo = sinon . stub ( ) . resolves ( ) ;
406
420
const setEnvironmentStub = sinon . stub ( ) ;
407
- const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub } ) ;
421
+ const systemStub = sinon . stub ( ) . returns ( { setEnvironment : setEnvironmentStub , loadOsInfo } ) ;
408
422
409
423
const Command = proxyquire ( modulePath , {
410
424
'./ui' : uiStub ,
@@ -437,7 +451,9 @@ describe('Unit: Command', function () {
437
451
expect ( setEnvironmentStub . calledOnce ) . to . be . true ;
438
452
expect ( setEnvironmentStub . calledWithExactly ( false , true ) ) . to . be . true ;
439
453
expect ( systemStub . calledOnce ) . to . be . true ;
440
- expect ( systemStub . calledWithExactly ( { error : errorStub } , [ { extensiona : true } ] ) ) . to . be . true ;
454
+ expect ( systemStub . calledWithExactly ( { error : errorStub , run} , [ { extensiona : true } ] ) ) . to . be . true ;
455
+ expect ( run . calledOnce ) . to . be . true ;
456
+ expect ( loadOsInfo . calledOnce ) . to . be . true ;
441
457
expect ( runStub . calledOnce ) . to . be . true ;
442
458
expect ( runStub . calledWithExactly ( { verbose : false , prompt : false , development : false , auto : false } ) ) . to . be . true ;
443
459
expect ( errorStub . calledOnce ) . to . be . true ;
0 commit comments