Skip to content

Commit 0e36bec

Browse files
targosaddaleax
authored andcommitted
test: refactor test-fs-non-number-arguments-throw
* Add RegExp arguments to throws assertions. * Use common.mustCall for emitter callback. PR-URL: #9844 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9099664 commit 0e36bec

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/parallel/test-fs-non-number-arguments-throw.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });
1515

1616
assert.throws(function() {
1717
fs.createReadStream(tempFile, { start: '4', end: 6 });
18-
}, "start as string didn't throw an error for createReadStream");
18+
}, /^TypeError: "start" option must be a Number$/,
19+
"start as string didn't throw an error for createReadStream");
1920

2021
assert.throws(function() {
2122
fs.createReadStream(tempFile, { start: 4, end: '6' });
22-
}, "end as string didn't throw an error");
23+
}, /^TypeError: "end" option must be a Number$/,
24+
"end as string didn't throw an error for createReadStream");
2325

2426
assert.throws(function() {
2527
fs.createWriteStream(tempFile, { start: '4' });
26-
}, "start as string didn't throw an error for createWriteStream");
28+
}, /^TypeError: "start" option must be a Number$/,
29+
"start as string didn't throw an error for createWriteStream");
2730

28-
saneEmitter.on('data', function(data) {
31+
saneEmitter.on('data', common.mustCall(function(data) {
2932
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +
3033
data.toString('utf8') + ' instead of ' + sanity);
31-
});
34+
}));

0 commit comments

Comments
 (0)