@@ -12,16 +12,14 @@ const { setTimeout } = require('timers/promises');
1212const tmpdir = require ( '../common/tmpdir' ) ;
1313
1414class WatchTestCase {
15- constructor ( shouldInclude , dirName , fileName , secondFileName , field ) {
15+ constructor ( shouldInclude , dirName , fileName , field ) {
1616 this . dirName = dirName ;
1717 this . fileName = fileName ;
18- this . secondFileName = secondFileName ;
1918 this . field = field ;
2019 this . shouldSkip = ! shouldInclude ;
2120 }
2221 get dirPath ( ) { return tmpdir . resolve ( this . dirName ) ; }
2322 get filePath ( ) { return join ( this . dirPath , this . fileName ) ; }
24- get secondFilePath ( ) { return join ( this . dirPath , this . secondFileName ) ; }
2523}
2624
2725const kCases = [
@@ -30,23 +28,13 @@ const kCases = [
3028 common . isLinux || common . isMacOS || common . isWindows || common . isAIX ,
3129 'watch1' ,
3230 'foo' ,
33- undefined ,
3431 'filePath'
3532 ) ,
3633 // Watch on a file should callback with a filename on supported systems
3734 new WatchTestCase (
3835 common . isLinux || common . isMacOS || common . isWindows ,
3936 'watch2' ,
4037 'bar' ,
41- undefined ,
42- 'dirPath'
43- ) ,
44- // Watch a path and ensure that no files are missed
45- new WatchTestCase (
46- common . isLinux || common . isMacOS || common . isWindows || common . isAIX ,
47- 'watch3' ,
48- 'foo' ,
49- 'bar' ,
5038 'dirPath'
5139 ) ,
5240] ;
@@ -59,11 +47,6 @@ for (const testCase of kCases) {
5947 // Long content so it's actually flushed.
6048 const content1 = Date . now ( ) + testCase . fileName . toLowerCase ( ) . repeat ( 1e4 ) ;
6149 fs . writeFileSync ( testCase . filePath , content1 ) ;
62- if ( testCase . secondFileName ) {
63- const content2 = Date . now ( ) + testCase . secondFileName . toLowerCase ( ) . repeat ( 1e4 ) ;
64- fs . writeFileSync ( testCase . secondFilePath , content2 ) ;
65- }
66-
6750
6851 let interval ;
6952 async function test ( ) {
@@ -74,19 +57,11 @@ for (const testCase of kCases) {
7457 }
7558
7659 const watcher = watch ( testCase [ testCase . field ] ) ;
77- let second = false ;
7860 for await ( const { eventType, filename } of watcher ) {
79- if ( ! second ) {
80- clearInterval ( interval ) ;
81- assert . strictEqual ( [ 'rename' , 'change' ] . includes ( eventType ) , true ) ;
82- assert . strictEqual ( filename , testCase . fileName ) ;
83- second = true ;
84- if ( ! testCase . secondFileName ) break ;
85- } else {
86- assert . strictEqual ( [ 'rename' , 'change' ] . includes ( eventType ) , true ) ;
87- assert . strictEqual ( filename , testCase . secondFileName ) ;
88- break ;
89- }
61+ clearInterval ( interval ) ;
62+ assert . strictEqual ( [ 'rename' , 'change' ] . includes ( eventType ) , true ) ;
63+ assert . strictEqual ( filename , testCase . fileName ) ;
64+ break ;
9065 }
9166
9267 // Waiting on it again is a non-op
0 commit comments