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 <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
targos authored and addaleax committed Dec 5, 2016
1 parent 9099664 commit 0e36bec
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 0e36bec

Please sign in to comment.