test: improve http res write and end dont take array

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Ilya Sotov 2018-04-21 13:41:10 +03:00 committed by Trivikram Kamat
parent 67e2a15d75
commit 12b90b4546

View File

@ -35,15 +35,26 @@ server.once('request', common.mustCall((req, res) => {
// write should accept buffer // write should accept buffer
res.write(Buffer.from('asdf')); res.write(Buffer.from('asdf'));
const expectedError = {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
};
// write should not accept an Array // write should not accept an Array
assert.throws(function() { assert.throws(
res.write(['array']); () => {
}, TypeError, 'first argument must be a string or Buffer'); res.write(['array']);
},
expectedError
);
// end should not accept an Array // end should not accept an Array
assert.throws(function() { assert.throws(
res.end(['moo']); () => {
}, TypeError, 'first argument must be a string or Buffer'); res.end(['moo']);
},
expectedError
);
// end should accept string // end should accept string
res.end('string'); res.end('string');