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: #9844
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
targos committed Dec 2, 2016
1 parent 24a98dd commit de495c0
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 de495c0

Please sign in to comment.