@@ -599,6 +599,55 @@ describe("Watchpack", function() {
599599 } ) ;
600600 } ) ;
601601
602+ it ( "should watch directory as file and directory" , function ( done ) {
603+ var w = new Watchpack ( {
604+ aggregateTimeout : 1000
605+ } ) ;
606+ w . on ( "aggregated" , function ( changes ) {
607+ const files = new Map ( ) ;
608+ const directories = new Map ( ) ;
609+ w . collectTimeInfoEntries ( files , directories ) ;
610+ // fixtures should exist
611+ const fixturesAsFile = files . get ( path . join ( fixtures ) ) ;
612+ fixturesAsFile . should . be . type ( "object" ) ;
613+ // dir should exist
614+ const dirAsFile = files . get ( path . join ( fixtures , "dir" ) ) ;
615+ dirAsFile . should . be . type ( "object" ) ;
616+ dirAsFile . should . not . have . property ( "safeTime" ) ;
617+ // a should have timestamp
618+ const a = files . get ( path . join ( fixtures , "dir" , "sub" , "a" ) ) ;
619+ a . should . be . type ( "object" ) ;
620+ a . should . have . property ( "safeTime" ) ;
621+ a . should . have . property ( "timestamp" ) ;
622+ // sub should have timestamp
623+ const sub = directories . get ( path . join ( fixtures , "dir" , "sub" ) ) ;
624+ sub . should . be . type ( "object" ) ;
625+ sub . should . have . property ( "safeTime" ) ;
626+ // sub should exist as file
627+ const subAsFile = files . get ( path . join ( fixtures , "dir" , "sub" ) ) ;
628+ subAsFile . should . be . type ( "object" ) ;
629+ subAsFile . should . not . have . property ( "safeTime" ) ;
630+ w . close ( ) ;
631+ done ( ) ;
632+ } ) ;
633+ testHelper . dir ( "dir" ) ;
634+ testHelper . dir ( path . join ( "dir" , "sub" ) ) ;
635+ testHelper . dir ( path . join ( "dir" , "sub2" ) ) ;
636+ testHelper . tick ( function ( ) {
637+ w . watch (
638+ [
639+ path . join ( fixtures , "dir" , "sub" , "a" ) ,
640+ path . join ( fixtures , "dir" , "sub" ) ,
641+ path . join ( fixtures )
642+ ] ,
643+ [ path . join ( fixtures , "dir" , "sub" ) ]
644+ ) ;
645+ testHelper . tick ( function ( ) {
646+ testHelper . file ( path . join ( "dir" , "sub" , "a" ) ) ;
647+ } ) ;
648+ } ) ;
649+ } ) ;
650+
602651 it ( "should watch 2 files in a not-existing directory" , function ( done ) {
603652 var w = new Watchpack ( {
604653 aggregateTimeout : 1000
0 commit comments