Permalink
Browse files

test: improve http res write and end dont take array

PR-URL: #20199
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
ilsotov authored and trivikr committed Apr 21, 2018
1 parent 67e2a15 commit 12b90b4546cdfef1adabaa661a33c98173a1a3f5
Showing with 17 additions and 6 deletions.
  1. +17 −6 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');

0 comments on commit 12b90b4

Please sign in to comment.