From 6970a77eb437c4757ce7b7948841a091f1d4c5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9?= Date: Thu, 7 Nov 2024 12:45:45 -0500 Subject: [PATCH] test: improve test coverage for `ServerResponse` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan José Arboleda PR-URL: https://github.com/nodejs/node/pull/55711 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: LiviaMedeiros --- test/parallel/test-http-write-head.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http-write-head.js b/test/parallel/test-http-write-head.js index e132f607ba0..1093a3ce5d6 100644 --- a/test/parallel/test-http-write-head.js +++ b/test/parallel/test-http-write-head.js @@ -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',