test: improve test coverage for ServerResponse

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/55711
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
This commit is contained in:
Juan José 2024-11-07 12:45:45 -05:00 committed by GitHub
parent 7788999ac1
commit 6970a77eb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,6 +51,12 @@ const s = http.createServer(common.mustCall((req, res) => {
}
);
assert.throws(() => {
res.writeHead(200, ['invalid', 'headers', 'args']);
}, {
code: 'ERR_INVALID_ARG_VALUE'
});
res.writeHead(200, { Test: '2' });
assert.throws(() => {
@ -78,7 +84,9 @@ function runTest() {
{
const server = http.createServer(common.mustCall((req, res) => {
res.writeHead(200, [ 'test', '1' ]);
res.writeHead(220, [ 'test', '1' ]); // 220 is not a standard status code
assert.strictEqual(res.statusMessage, 'unknown');
assert.throws(() => res.writeHead(200, [ 'test2', '2' ]), {
code: 'ERR_HTTP_HEADERS_SENT',
name: 'Error',