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:
parent
67e2a15d75
commit
12b90b4546
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user