@@ -367,7 +367,7 @@ describe('Unit: Instance', function () {
367
367
describe ( 'template' , function ( ) {
368
368
it ( 'resolves with false if the choice is to skip' , function ( ) {
369
369
let promptStub = sandbox . stub ( ) . resolves ( { choice : 'skip' } ) ;
370
- let testInstance = new Instance ( { prompt : promptStub } , { } , '' ) ;
370
+ let testInstance = new Instance ( { prompt : promptStub , allowPrompt : true } , { } , '' ) ;
371
371
372
372
return testInstance . template ( 'some contents' , 'a file' , 'file.txt' , '/some/dir' ) . then ( ( result ) => {
373
373
expect ( promptStub . calledOnce ) . to . be . true ;
@@ -377,7 +377,7 @@ describe('Unit: Instance', function () {
377
377
378
378
it ( 'generates template if the choice is to proceeed' , function ( ) {
379
379
let promptStub = sandbox . stub ( ) . resolves ( { choice : 'write' } ) ;
380
- let testInstance = new Instance ( { prompt : promptStub } , { } , '' ) ;
380
+ let testInstance = new Instance ( { prompt : promptStub , allowPrompt : true } , { } , '' ) ;
381
381
let generateStub = sandbox . stub ( testInstance , '_generateTemplate' ) . resolves ( true ) ;
382
382
383
383
return testInstance . template ( 'some contents' , 'a file' , 'file.txt' , '/some/dir' ) . then ( ( result ) => {
@@ -393,7 +393,7 @@ describe('Unit: Instance', function () {
393
393
promptStub . onCall ( 0 ) . resolves ( { choice : 'view' } ) ;
394
394
promptStub . onCall ( 1 ) . resolves ( { choice : 'skip' } ) ;
395
395
let logStub = sandbox . stub ( ) ;
396
- let testInstance = new Instance ( { log : logStub , prompt : promptStub } , { } , '' ) ;
396
+ let testInstance = new Instance ( { log : logStub , prompt : promptStub , allowPrompt : true } , { } , '' ) ;
397
397
398
398
return testInstance . template ( 'some contents' , 'a file' , 'file.txt' , '/some/dir' ) . then ( ( result ) => {
399
399
expect ( result ) . to . be . false ;
@@ -407,7 +407,7 @@ describe('Unit: Instance', function () {
407
407
let promptStub = sandbox . stub ( ) ;
408
408
promptStub . onCall ( 0 ) . resolves ( { choice : 'edit' } ) ;
409
409
promptStub . onCall ( 1 ) . resolves ( { contents : 'some edited contents' } ) ;
410
- let testInstance = new Instance ( { prompt : promptStub } , { } , '' ) ;
410
+ let testInstance = new Instance ( { prompt : promptStub , allowPrompt : true } , { } , '' ) ;
411
411
let generateStub = sandbox . stub ( testInstance , '_generateTemplate' ) . resolves ( true ) ;
412
412
413
413
return testInstance . template ( 'some contents' , 'a file' , 'file.txt' , '/some/dir' ) . then ( ( result ) => {
@@ -417,6 +417,22 @@ describe('Unit: Instance', function () {
417
417
expect ( generateStub . args [ 0 ] [ 0 ] ) . to . equal ( 'some edited contents' ) ;
418
418
} ) ;
419
419
} ) ;
420
+
421
+ it ( 'immediately calls _generateTemplate if ui.allowPrompt is false' , function ( ) {
422
+ let promptStub = sandbox . stub ( ) . resolves ( ) ;
423
+ let testInstance = new Instance ( {
424
+ prompt : promptStub ,
425
+ allowPrompt : false
426
+ } , { } , '' ) ;
427
+ let generateStub = sandbox . stub ( testInstance , '_generateTemplate' ) . resolves ( true ) ;
428
+
429
+ return testInstance . template ( 'some contents' , 'a file' , 'file.txt' , '/some/dir' ) . then ( ( result ) => {
430
+ expect ( result ) . to . be . true ;
431
+ expect ( promptStub . called ) . to . be . false ;
432
+ expect ( generateStub . calledOnce ) . to . be . true ;
433
+ expect ( generateStub . args [ 0 ] [ 0 ] ) . to . equal ( 'some contents' ) ;
434
+ } ) ;
435
+ } ) ;
420
436
} ) ;
421
437
422
438
describe ( '_generateTemplate' , function ( ) {
0 commit comments