Skip to content

Commit

Permalink
test: improve test coverage for ServerResponse
Browse files Browse the repository at this point in the history
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: #55711
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
  • Loading branch information
juanarbol authored and aduh95 committed Nov 16, 2024
1 parent cfe28b1 commit d1ad43e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/parallel/test-http-write-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit d1ad43e

Please sign in to comment.