Skip to content

Commit

Permalink
test: refactor test-fs-non-number-arguments-throw
Browse files Browse the repository at this point in the history
* Add RegExp arguments to throws assertions.
* Use common.mustCall for emitter callback.

PR-URL: nodejs#9844
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
targos authored and addaleax committed Dec 8, 2016
1 parent 74919eb commit 015812e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/parallel/test-fs-non-number-arguments-throw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });

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

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

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

saneEmitter.on('data', function(data) {
saneEmitter.on('data', common.mustCall(function(data) {
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +
data.toString('utf8') + ' instead of ' + sanity);
});
}));

0 comments on commit 015812e

Please sign in to comment.