diff options
author | LakshmiSwethaG <lakshmigopireddy@in.ibm.com> | 2019-01-16 05:24:43 -0500 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-02-08 14:42:04 +0100 |
commit | 0f0e7f55f86d065b77de5e9d6a91637aac09372a (patch) | |
tree | 91b5b67933ac54f06d4852e01feb3989de2f2a5f /test | |
parent | 62942e9ad7a59b76e9255ea2560bad2245709efc (diff) | |
download | android-node-v8-0f0e7f55f86d065b77de5e9d6a91637aac09372a.tar.gz android-node-v8-0f0e7f55f86d065b77de5e9d6a91637aac09372a.tar.bz2 android-node-v8-0f0e7f55f86d065b77de5e9d6a91637aac09372a.zip |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-fs-watch-encoding.js | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/test/parallel/test-fs-watch-encoding.js b/test/parallel/test-fs-watch-encoding.js index 1cea625509..13b4dc340e 100644 --- a/test/parallel/test-fs-watch-encoding.js +++ b/test/parallel/test-fs-watch-encoding.js @@ -42,36 +42,45 @@ function unregisterWatcher(watcher) { } } -const watcher1 = fs.watch( - tmpdir.path, - { encoding: 'hex' }, - (event, filename) => { - if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename)) - done(watcher1); - } -); -registerWatcher(watcher1); +{ + // Test that using the `encoding` option has the expected result. + const watcher = fs.watch( + tmpdir.path, + { encoding: 'hex' }, + (event, filename) => { + if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename)) + done(watcher); + } + ); + registerWatcher(watcher); +} -const watcher2 = fs.watch( - tmpdir.path, - (event, filename) => { - if ([fn, null].includes(filename)) - done(watcher2); - } -); -registerWatcher(watcher2); +{ + // Test that in absence of `encoding` option has the expected result. + const watcher = fs.watch( + tmpdir.path, + (event, filename) => { + if ([fn, null].includes(filename)) + done(watcher); + } + ); + registerWatcher(watcher); +} -const watcher3 = fs.watch( - tmpdir.path, - { encoding: 'buffer' }, - (event, filename) => { - if (filename instanceof Buffer && filename.toString('utf8') === fn) - done(watcher3); - else if (filename === null) - done(watcher3); - } -); -registerWatcher(watcher3); +{ + // Test that using the `encoding` option has the expected result. + const watcher = fs.watch( + tmpdir.path, + { encoding: 'buffer' }, + (event, filename) => { + if (filename instanceof Buffer && filename.toString('utf8') === fn) + done(watcher); + else if (filename === null) + done(watcher); + } + ); + registerWatcher(watcher); +} const done = common.mustCall(unregisterWatcher, watchers.size); |