test: refactor to block-scope
PR-URL: https://github.com/nodejs/node/pull/25532 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
62942e9ad7
commit
0f0e7f55f8
@ -42,36 +42,45 @@ function unregisterWatcher(watcher) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const watcher1 = fs.watch(
|
{
|
||||||
tmpdir.path,
|
// Test that using the `encoding` option has the expected result.
|
||||||
{ encoding: 'hex' },
|
const watcher = fs.watch(
|
||||||
(event, filename) => {
|
tmpdir.path,
|
||||||
if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
|
{ encoding: 'hex' },
|
||||||
done(watcher1);
|
(event, filename) => {
|
||||||
}
|
if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
|
||||||
);
|
done(watcher);
|
||||||
registerWatcher(watcher1);
|
}
|
||||||
|
);
|
||||||
|
registerWatcher(watcher);
|
||||||
|
}
|
||||||
|
|
||||||
const watcher2 = fs.watch(
|
{
|
||||||
tmpdir.path,
|
// Test that in absence of `encoding` option has the expected result.
|
||||||
(event, filename) => {
|
const watcher = fs.watch(
|
||||||
if ([fn, null].includes(filename))
|
tmpdir.path,
|
||||||
done(watcher2);
|
(event, filename) => {
|
||||||
}
|
if ([fn, null].includes(filename))
|
||||||
);
|
done(watcher);
|
||||||
registerWatcher(watcher2);
|
}
|
||||||
|
);
|
||||||
|
registerWatcher(watcher);
|
||||||
|
}
|
||||||
|
|
||||||
const watcher3 = fs.watch(
|
{
|
||||||
tmpdir.path,
|
// Test that using the `encoding` option has the expected result.
|
||||||
{ encoding: 'buffer' },
|
const watcher = fs.watch(
|
||||||
(event, filename) => {
|
tmpdir.path,
|
||||||
if (filename instanceof Buffer && filename.toString('utf8') === fn)
|
{ encoding: 'buffer' },
|
||||||
done(watcher3);
|
(event, filename) => {
|
||||||
else if (filename === null)
|
if (filename instanceof Buffer && filename.toString('utf8') === fn)
|
||||||
done(watcher3);
|
done(watcher);
|
||||||
}
|
else if (filename === null)
|
||||||
);
|
done(watcher);
|
||||||
registerWatcher(watcher3);
|
}
|
||||||
|
);
|
||||||
|
registerWatcher(watcher);
|
||||||
|
}
|
||||||
|
|
||||||
const done = common.mustCall(unregisterWatcher, watchers.size);
|
const done = common.mustCall(unregisterWatcher, watchers.size);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user