From 0e36becd39953d40b4e8083b61b9b0e3b990bf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 29 Nov 2016 20:28:08 +0100 Subject: [PATCH] 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 Reviewed-By: Luigi Pinca --- test/parallel/test-fs-non-number-arguments-throw.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-fs-non-number-arguments-throw.js b/test/parallel/test-fs-non-number-arguments-throw.js index 8f34a1fcbb92b1..b13041ca3eecb6 100644 --- a/test/parallel/test-fs-non-number-arguments-throw.js +++ b/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); -}); +}));