Skip to content

Commit b65d5e4

Browse files
RobotMermaidTrott
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 <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent c405497 commit b65d5e4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/sequential/test-fs-watch.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ assert.doesNotThrow(
5757
function() {
5858
const watcher = fs.watch(filepathOne);
5959
watcher.on('change', function(event, filename) {
60-
assert.strictEqual('change', event);
60+
assert.strictEqual(event, 'change');
6161

6262
if (expectFilePath) {
63-
assert.strictEqual('watch.txt', filename);
63+
assert.strictEqual(filename, 'watch.txt');
6464
}
6565
watcher.close();
6666
++watchSeenOne;
@@ -80,10 +80,10 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
8080
assert.doesNotThrow(
8181
function() {
8282
const watcher = fs.watch(filepathTwo, function(event, filename) {
83-
assert.strictEqual('change', event);
83+
assert.strictEqual(event, 'change');
8484

8585
if (expectFilePath) {
86-
assert.strictEqual('hasOwnProperty', filename);
86+
assert.strictEqual(filename, 'hasOwnProperty');
8787
}
8888
watcher.close();
8989
++watchSeenTwo;
@@ -103,11 +103,11 @@ assert.doesNotThrow(
103103
function() {
104104
const watcher = fs.watch(testsubdir, function(event, filename) {
105105
const renameEv = common.isSunOS || common.isAix ? 'change' : 'rename';
106-
assert.strictEqual(renameEv, event);
106+
assert.strictEqual(event, renameEv);
107107
if (expectFilePath) {
108-
assert.strictEqual('newfile.txt', filename);
108+
assert.strictEqual(filename, 'newfile.txt');
109109
} else {
110-
assert.strictEqual(null, filename);
110+
assert.strictEqual(filename, null);
111111
}
112112
watcher.close();
113113
++watchSeenThree;
@@ -134,13 +134,13 @@ assert.throws(function() {
134134
oldhandle = w._handle;
135135
w._handle = { close: w._handle.close };
136136
w.close();
137-
}, TypeError);
137+
}, /^TypeError: Illegal invocation$/);
138138
oldhandle.close(); // clean up
139139

140140
assert.throws(function() {
141141
const w = fs.watchFile(__filename, {persistent: false}, common.noop);
142142
oldhandle = w._handle;
143143
w._handle = { stop: w._handle.stop };
144144
w.stop();
145-
}, TypeError);
145+
}, /^TypeError: Illegal invocation$/);
146146
oldhandle.stop(); // clean up

0 commit comments

Comments
 (0)