Skip to content

Commit 0ddc060

Browse files
ilsotovjasnell
authored andcommitted
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>
1 parent a342cd6 commit 0ddc060

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

test/parallel/test-http-res-write-end-dont-take-array.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,26 @@ server.once('request', common.mustCall((req, res) => {
3535
// write should accept buffer
3636
res.write(Buffer.from('asdf'));
3737

38+
const expectedError = {
39+
code: 'ERR_INVALID_ARG_TYPE',
40+
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
41+
};
42+
3843
// write should not accept an Array
39-
assert.throws(function() {
40-
res.write(['array']);
41-
}, TypeError, 'first argument must be a string or Buffer');
44+
assert.throws(
45+
() => {
46+
res.write(['array']);
47+
},
48+
expectedError
49+
);
4250

4351
// end should not accept an Array
44-
assert.throws(function() {
45-
res.end(['moo']);
46-
}, TypeError, 'first argument must be a string or Buffer');
52+
assert.throws(
53+
() => {
54+
res.end(['moo']);
55+
},
56+
expectedError
57+
);
4758

4859
// end should accept string
4960
res.end('string');

0 commit comments

Comments
 (0)