Skip to content

Commit a714449

Browse files
RobotMermaidMylesBorins
authored andcommitted
test: cleanup test-fs-watch.js
Reversed "actual" and "expected" arguments for assert.strictEqual(). Replaced constructor with regular expression for assert.throws(). PR-URL: #12595 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
1 parent 89e76e8 commit a714449

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/sequential/test-fs-watch.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ assert.doesNotThrow(
3535
function() {
3636
const watcher = fs.watch(filepathOne);
3737
watcher.on('change', function(event, filename) {
38-
assert.strictEqual('change', event);
38+
assert.strictEqual(event, 'change');
3939

4040
if (expectFilePath) {
41-
assert.strictEqual('watch.txt', filename);
41+
assert.strictEqual(filename, 'watch.txt');
4242
}
4343
watcher.close();
4444
++watchSeenOne;
@@ -58,10 +58,10 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
5858
assert.doesNotThrow(
5959
function() {
6060
const watcher = fs.watch(filepathTwo, function(event, filename) {
61-
assert.strictEqual('change', event);
61+
assert.strictEqual(event, 'change');
6262

6363
if (expectFilePath) {
64-
assert.strictEqual('hasOwnProperty', filename);
64+
assert.strictEqual(filename, 'hasOwnProperty');
6565
}
6666
watcher.close();
6767
++watchSeenTwo;
@@ -83,9 +83,9 @@ assert.doesNotThrow(
8383
const renameEv = common.isSunOS ? 'change' : 'rename';
8484
assert.strictEqual(renameEv, event);
8585
if (expectFilePath) {
86-
assert.strictEqual('newfile.txt', filename);
86+
assert.strictEqual(filename, 'newfile.txt');
8787
} else {
88-
assert.strictEqual(null, filename);
88+
assert.strictEqual(filename, null);
8989
}
9090
watcher.close();
9191
++watchSeenThree;
@@ -112,13 +112,13 @@ assert.throws(function() {
112112
oldhandle = w._handle;
113113
w._handle = { close: w._handle.close };
114114
w.close();
115-
}, TypeError);
115+
}, /^TypeError: Illegal invocation$/);
116116
oldhandle.close(); // clean up
117117

118118
assert.throws(function() {
119119
const w = fs.watchFile(__filename, {persistent: false}, function() {});
120120
oldhandle = w._handle;
121121
w._handle = { stop: w._handle.stop };
122122
w.stop();
123-
}, TypeError);
123+
}, /^TypeError: Illegal invocation$/);
124124
oldhandle.stop(); // clean up

0 commit comments

Comments
 (0)