From 12b90b4546cdfef1adabaa661a33c98173a1a3f5 Mon Sep 17 00:00:00 2001 From: Ilya Sotov Date: Sat, 21 Apr 2018 13:41:10 +0300 Subject: [PATCH] test: improve http res write and end dont take array PR-URL: https://github.com/nodejs/node/pull/20199 Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Rich Trott --- ...test-http-res-write-end-dont-take-array.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-http-res-write-end-dont-take-array.js b/test/parallel/test-http-res-write-end-dont-take-array.js index 94b105cb181..fbe71bd6fcb 100644 --- a/test/parallel/test-http-res-write-end-dont-take-array.js +++ b/test/parallel/test-http-res-write-end-dont-take-array.js @@ -35,15 +35,26 @@ server.once('request', common.mustCall((req, res) => { // write should accept buffer res.write(Buffer.from('asdf')); + const expectedError = { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError [ERR_INVALID_ARG_TYPE]', + }; + // write should not accept an Array - assert.throws(function() { - res.write(['array']); - }, TypeError, 'first argument must be a string or Buffer'); + assert.throws( + () => { + res.write(['array']); + }, + expectedError + ); // end should not accept an Array - assert.throws(function() { - res.end(['moo']); - }, TypeError, 'first argument must be a string or Buffer'); + assert.throws( + () => { + res.end(['moo']); + }, + expectedError + ); // end should accept string res.end('string');