@@ -508,91 +508,93 @@ group('chokidar is installed', function (beforeEach, test, group) {
508508 } ) ;
509509 } ) ;
510510
511- test ( 'reruns initial tests when "rs" is entered on stdin' , function ( t ) {
512- t . plan ( 2 ) ;
513- api . run . returns ( Promise . resolve ( ) ) ;
514- start ( ) . observeStdin ( stdin ) ;
511+ [ "r" , "rs" ] . forEach ( function ( input ) {
512+ test ( 'reruns initial tests when "' + input + '" is entered on stdin' , function ( t ) {
513+ t . plan ( 2 ) ;
514+ api . run . returns ( Promise . resolve ( ) ) ;
515+ start ( ) . observeStdin ( stdin ) ;
515516
516- stdin . write ( 'rs \n') ;
517- return delay ( ) . then ( function ( ) {
518- t . ok ( api . run . calledTwice ) ;
517+ stdin . write ( input + ' \n') ;
518+ return delay ( ) . then ( function ( ) {
519+ t . ok ( api . run . calledTwice ) ;
519520
520- stdin . write ( '\trs \n' ) ;
521- return delay ( ) ;
522- } ) . then ( function ( ) {
523- t . ok ( api . run . calledThrice ) ;
521+ stdin . write ( '\t' + input + ' \n' ) ;
522+ return delay ( ) ;
523+ } ) . then ( function ( ) {
524+ t . ok ( api . run . calledThrice ) ;
525+ } ) ;
524526 } ) ;
525- } ) ;
526527
527- test ( 'entering "rs " on stdin cancels any debouncing' , function ( t ) {
528- t . plan ( 7 ) ;
529- api . run . returns ( Promise . resolve ( ) ) ;
530- start ( ) . observeStdin ( stdin ) ;
528+ test ( 'entering "' + input + ' " on stdin cancels any debouncing', function ( t ) {
529+ t . plan ( 7 ) ;
530+ api . run . returns ( Promise . resolve ( ) ) ;
531+ start ( ) . observeStdin ( stdin ) ;
531532
532- var before = clock . now ;
533- var done ;
534- api . run . returns ( new Promise ( function ( resolve ) {
535- done = resolve ;
536- } ) ) ;
533+ var before = clock . now ;
534+ var done ;
535+ api . run . returns ( new Promise ( function ( resolve ) {
536+ done = resolve ;
537+ } ) ) ;
537538
538- add ( ) ;
539- stdin . write ( 'rs \n') ;
540- return delay ( ) . then ( function ( ) {
541- // Processing "rs" caused a new run.
542- t . ok ( api . run . calledTwice ) ;
539+ add ( ) ;
540+ stdin . write ( input + ' \n') ;
541+ return delay ( ) . then ( function ( ) {
542+ // Processing "rs" caused a new run.
543+ t . ok ( api . run . calledTwice ) ;
543544
544- // Try to advance the clock. This is *after* "rs" was processed. The
545- // debounce timeout should have been canceled, so the clock can't have
546- // advanced.
547- clock . next ( ) ;
548- t . is ( before , clock . now ) ;
545+ // Try to advance the clock. This is *after* input was processed. The
546+ // debounce timeout should have been canceled, so the clock can't have
547+ // advanced.
548+ clock . next ( ) ;
549+ t . is ( before , clock . now ) ;
549550
550- add ( ) ;
551- // Advance clock *before* "rs" is received. Note that the previous run
552- // hasn't finished yet.
553- clock . next ( ) ;
554- stdin . write ( 'rs \n') ;
551+ add ( ) ;
552+ // Advance clock *before* input is received. Note that the previous run
553+ // hasn't finished yet.
554+ clock . next ( ) ;
555+ stdin . write ( input + ' \n') ;
555556
556- return delay ( ) ;
557- } ) . then ( function ( ) {
558- // No new runs yet.
559- t . ok ( api . run . calledTwice ) ;
560- // Though the clock has advanced.
561- t . is ( clock . now - before , 10 ) ;
562- before = clock . now ;
557+ return delay ( ) ;
558+ } ) . then ( function ( ) {
559+ // No new runs yet.
560+ t . ok ( api . run . calledTwice ) ;
561+ // Though the clock has advanced.
562+ t . is ( clock . now - before , 10 ) ;
563+ before = clock . now ;
563564
564- var previous = done ;
565- api . run . returns ( new Promise ( function ( resolve ) {
566- done = resolve ;
567- } ) ) ;
565+ var previous = done ;
566+ api . run . returns ( new Promise ( function ( resolve ) {
567+ done = resolve ;
568+ } ) ) ;
568569
569- // Finish the previous run.
570- previous ( ) ;
570+ // Finish the previous run.
571+ previous ( ) ;
571572
572- return delay ( ) ;
573- } ) . then ( function ( ) {
574- // There's only one new run.
575- t . ok ( api . run . calledThrice ) ;
573+ return delay ( ) ;
574+ } ) . then ( function ( ) {
575+ // There's only one new run.
576+ t . ok ( api . run . calledThrice ) ;
576577
577- stdin . write ( 'rs \n') ;
578- return delay ( ) ;
579- } ) . then ( function ( ) {
580- add ( ) ;
578+ stdin . write ( input + ' \n') ;
579+ return delay ( ) ;
580+ } ) . then ( function ( ) {
581+ add ( ) ;
581582
582- // Finish the previous run. This should cause a new run due to the "rs"
583- // input.
584- done ( ) ;
583+ // Finish the previous run. This should cause a new run due to the
584+ // input.
585+ done ( ) ;
585586
586- return delay ( ) ;
587- } ) . then ( function ( ) {
588- // Again there's only one new run.
589- t . is ( api . run . callCount , 4 ) ;
587+ return delay ( ) ;
588+ } ) . then ( function ( ) {
589+ // Again there's only one new run.
590+ t . is ( api . run . callCount , 4 ) ;
590591
591- // Try to advance the clock. This is *after* "rs" was processed. The
592- // debounce timeout should have been canceled, so the clock can't have
593- // advanced.
594- clock . next ( ) ;
595- t . is ( before , clock . now ) ;
592+ // Try to advance the clock. This is *after* input was processed. The
593+ // debounce timeout should have been canceled, so the clock can't have
594+ // advanced.
595+ clock . next ( ) ;
596+ t . is ( before , clock . now ) ;
597+ } ) ;
596598 } ) ;
597599 } ) ;
598600
0 commit comments