Skip to content

Commit 120a471

Browse files
Eran LevinTrott
Eran Levin
authored andcommitted
updating test.
1 parent 7e23cef commit 120a471

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

test/parallel/test-fs-watch-recursive.js

+23-28
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,34 @@ const filepathOne = path.join(testsubdir, filenameOne);
2121
if (!common.isOSX && !common.isWindows) {
2222
common.expectsError(() => fs.watch(testDir, { recursive: true }),
2323
{ code: 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM' });
24-
} else {
25-
26-
testWhenRecursiveIsImplemented();
24+
return;
2725
}
26+
const watcher = fs.watch(testDir, { recursive: true });
2827

29-
function testWhenRecursiveIsImplemented() {
30-
const watcher = fs.watch(testDir, { recursive: true });
31-
32-
let watcherClosed = false;
33-
watcher.on('change', function(event, filename) {
34-
assert.ok(event === 'change' || event === 'rename');
35-
36-
// Ignore stale events generated by mkdir and other tests
37-
if (filename !== relativePathOne)
38-
return;
28+
let watcherClosed = false;
29+
watcher.on('change', function(event, filename) {
30+
assert.ok(event === 'change' || event === 'rename');
3931

40-
if (common.isOSX) {
41-
clearInterval(interval);
42-
}
43-
watcher.close();
44-
watcherClosed = true;
45-
});
32+
// Ignore stale events generated by mkdir and other tests
33+
if (filename !== relativePathOne)
34+
return;
4635

47-
let interval;
4836
if (common.isOSX) {
49-
interval = setInterval(function() {
50-
fs.writeFileSync(filepathOne, 'world');
51-
}, 10);
52-
} else {
53-
fs.writeFileSync(filepathOne, 'world');
37+
clearInterval(interval);
5438
}
39+
watcher.close();
40+
watcherClosed = true;
41+
});
5542

56-
process.on('exit', function() {
57-
assert(watcherClosed, 'watcher Object was not closed');
58-
});
43+
let interval;
44+
if (common.isOSX) {
45+
interval = setInterval(function() {
46+
fs.writeFileSync(filepathOne, 'world');
47+
}, 10);
48+
} else {
49+
fs.writeFileSync(filepathOne, 'world');
5950
}
51+
52+
process.on('exit', function() {
53+
assert(watcherClosed, 'watcher Object was not closed');
54+
});

0 commit comments

Comments
 (0)