Browse Source

test: refactor test-fs-non-number-arguments-throw

* Add RegExp arguments to throws assertions.
* Use common.mustCall for emitter callback.

PR-URL: https://github.com/nodejs/node/pull/9844
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v6
Michaël Zasso 8 years ago
parent
commit
de495c0669
  1. 13
      test/parallel/test-fs-non-number-arguments-throw.js

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

@ -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);
});
}));

Loading…
Cancel
Save