Skip to content

Commit

Permalink
test: improve http res write and end dont take array
Browse files Browse the repository at this point in the history
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 23, 2018
1 parent 67e2a15 commit 12b90b4
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/parallel/test-http-res-write-end-dont-take-array.js
Expand Up @@ -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');
Expand Down

0 comments on commit 12b90b4

Please sign in to comment.