Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve http res write and end dont take array #20199

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions test/parallel/test-http-res-write-end-dont-take-array.js
Original file line number Diff line number Diff line change
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