@@ -169,9 +169,8 @@ const runTests = function(baseopts) {
169
169
watcher . on ( 'add' , ( path ) => {
170
170
spy ( path ) ;
171
171
} ) ;
172
- await waitForWatcher ( watcher ) ;
173
172
174
- await delay ( ) ;
173
+ await waitForWatcher ( watcher ) ;
175
174
176
175
( async ( ) => {
177
176
for ( let path of paths . slice ( 0 , 5 ) ) {
@@ -184,6 +183,7 @@ const runTests = function(baseopts) {
184
183
delay ( ) ;
185
184
} ) ( ) ;
186
185
186
+ await waitFor ( [ [ spy , 4 ] ] ) ;
187
187
await waitFor ( [ [ spy , 9 ] ] ) ;
188
188
paths . forEach ( path => {
189
189
spy . should . have . been . calledWith ( path ) ;
@@ -278,6 +278,8 @@ const runTests = function(baseopts) {
278
278
await write ( testg1Path , Date . now ( ) ) ;
279
279
await write ( testh1Path , Date . now ( ) ) ;
280
280
await write ( testi1Path , Date . now ( ) ) ;
281
+ await waitFor ( [ [ spy , 11 ] ] ) ;
282
+ await waitFor ( [ [ spy , 22 ] ] ) ;
281
283
await waitFor ( [ [ spy , 33 ] ] ) ;
282
284
283
285
spy . should . have . been . calledWith ( test1Path ) ;
@@ -757,25 +759,31 @@ const runTests = function(baseopts) {
757
759
} ) ;
758
760
it ( 'should traverse subdirs to match globstar patterns' , async ( ) => {
759
761
const watchPath = getGlobPath ( '../../test-*/' + subdirId + '/**/a*.txt' ) ;
760
- fs . mkdirSync ( getFixturePath ( 'subdir' ) , PERM_ARR ) ;
761
- fs . mkdirSync ( getFixturePath ( 'subdir/subsub' ) , PERM_ARR ) ;
762
- fs . writeFileSync ( getFixturePath ( 'subdir/a.txt' ) , 'b' ) ;
763
- fs . writeFileSync ( getFixturePath ( 'subdir/b.txt' ) , 'b' ) ;
764
- fs . writeFileSync ( getFixturePath ( 'subdir/subsub/ab.txt' ) , 'b' ) ;
762
+ const addFile = getFixturePath ( 'add.txt' ) ;
763
+ const subdir = getFixturePath ( 'subdir' ) ;
764
+ const subsubdir = getFixturePath ( 'subdir/subsub' ) ;
765
+ const aFile = getFixturePath ( 'subdir/a.txt' ) ;
766
+ const bFile = getFixturePath ( 'subdir/b.txt' ) ;
767
+ const subFile = getFixturePath ( 'subdir/subsub/ab.txt' ) ;
768
+ fs . mkdirSync ( subdir , PERM_ARR ) ;
769
+ fs . mkdirSync ( subsubdir , PERM_ARR ) ;
770
+ fs . writeFileSync ( aFile , 'b' ) ;
771
+ fs . writeFileSync ( bFile , 'b' ) ;
772
+ fs . writeFileSync ( subFile , 'b' ) ;
765
773
766
774
await delay ( ) ;
767
775
let watcher = chokidar_watch ( watchPath , options ) ;
768
776
const spy = await aspy ( watcher , 'all' ) ;
769
777
setTimeout ( async ( ) => {
770
- await write ( getFixturePath ( 'add.txt' ) , Date . now ( ) ) ;
771
- await write ( getFixturePath ( 'subdir/subsub/ab.txt' ) , Date . now ( ) ) ;
772
- await fs_unlink ( getFixturePath ( 'subdir/a.txt' ) ) ;
773
- await fs_unlink ( getFixturePath ( 'subdir/b.txt' ) ) ;
778
+ await write ( addFile , Date . now ( ) ) ;
779
+ await write ( subFile , Date . now ( ) ) ;
780
+ await fs_unlink ( aFile ) ;
781
+ await fs_unlink ( bFile ) ;
774
782
} , 50 ) ;
775
783
await waitFor ( [ [ spy . withArgs ( 'add' ) , 3 ] , spy . withArgs ( 'unlink' ) , spy . withArgs ( 'change' ) ] ) ;
776
784
spy . withArgs ( 'add' ) . should . have . been . calledThrice ;
777
- spy . should . have . been . calledWith ( 'unlink' , getFixturePath ( 'subdir/a.txt' ) ) ;
778
- spy . should . have . been . calledWith ( 'change' , getFixturePath ( 'subdir/subsub/ab.txt' ) ) ;
785
+ spy . should . have . been . calledWith ( 'unlink' , aFile ) ;
786
+ spy . should . have . been . calledWith ( 'change' , subFile ) ;
779
787
spy . withArgs ( 'unlink' ) . should . have . been . calledOnce ;
780
788
spy . withArgs ( 'change' ) . should . have . been . calledOnce ;
781
789
} ) ;
@@ -831,8 +839,8 @@ const runTests = function(baseopts) {
831
839
spy . should . have . been . calledWith ( 'add' , changePath ) ;
832
840
spy . should . have . been . calledOnce ;
833
841
834
- await delay ( ) ;
835
842
await write ( changePath , Date . now ( ) ) ;
843
+ await delay ( ) ;
836
844
await waitFor ( [ [ spy , 2 ] ] ) ;
837
845
spy . should . have . been . calledWith ( 'change' , changePath ) ;
838
846
spy . should . have . been . calledTwice ;
0 commit comments