Skip to content

Commit

Permalink
test: cleanup test-fs-watch.js
Browse files Browse the repository at this point in the history
Reversed "actual" and "expected" arguments for assert.strictEqual().

Replaced constructor with regular expression for assert.throws().

PR-URL: #12595
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Bryan English <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
  • Loading branch information
RobotMermaid authored and evanlucas committed May 2, 2017
1 parent d15b1c4 commit e36a256
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ assert.doesNotThrow(
function() {
const watcher = fs.watch(filepathOne);
watcher.on('change', function(event, filename) {
assert.strictEqual('change', event);
assert.strictEqual(event, 'change');

if (expectFilePath) {
assert.strictEqual('watch.txt', filename);
assert.strictEqual(filename, 'watch.txt');
}
watcher.close();
++watchSeenOne;
Expand All @@ -59,10 +59,10 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
assert.doesNotThrow(
function() {
const watcher = fs.watch(filepathTwo, function(event, filename) {
assert.strictEqual('change', event);
assert.strictEqual(event, 'change');

if (expectFilePath) {
assert.strictEqual('hasOwnProperty', filename);
assert.strictEqual(filename, 'hasOwnProperty');
}
watcher.close();
++watchSeenTwo;
Expand All @@ -82,11 +82,11 @@ assert.doesNotThrow(
function() {
const watcher = fs.watch(testsubdir, function(event, filename) {
const renameEv = common.isSunOS || common.isAix ? 'change' : 'rename';
assert.strictEqual(renameEv, event);
assert.strictEqual(event, renameEv);
if (expectFilePath) {
assert.strictEqual('newfile.txt', filename);
assert.strictEqual(filename, 'newfile.txt');
} else {
assert.strictEqual(null, filename);
assert.strictEqual(filename, null);
}
watcher.close();
++watchSeenThree;
Expand All @@ -113,13 +113,13 @@ assert.throws(function() {
oldhandle = w._handle;
w._handle = { close: w._handle.close };
w.close();
}, TypeError);
}, /^TypeError: Illegal invocation$/);
oldhandle.close(); // clean up

assert.throws(function() {
const w = fs.watchFile(__filename, {persistent: false}, function() {});
oldhandle = w._handle;
w._handle = { stop: w._handle.stop };
w.stop();
}, TypeError);
}, /^TypeError: Illegal invocation$/);
oldhandle.stop(); // clean up

0 comments on commit e36a256

Please sign in to comment.