From 6d422ad807b1edeb024e9f8d7df69c8417ad8477 Mon Sep 17 00:00:00 2001 From: Yoshiki Kurihara Date: Tue, 15 Mar 2022 08:28:20 +0900 Subject: [PATCH] test: improve _http_incoming.js coverage PR-URL: https://github.com/nodejs/node/pull/42211 Refs: https://coverage.nodejs.org/coverage-010cb714161102de/lib/_http_incoming.js.html Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- .../test-set-incoming-message-header.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/parallel/test-set-incoming-message-header.js diff --git a/test/parallel/test-set-incoming-message-header.js b/test/parallel/test-set-incoming-message-header.js new file mode 100644 index 00000000000000..9ac05a8138d445 --- /dev/null +++ b/test/parallel/test-set-incoming-message-header.js @@ -0,0 +1,27 @@ +'use strict'; + +require('../common'); +const { IncomingMessage } = require('http'); +const assert = require('assert'); + +// Headers setter function set a header correctly +{ + const im = new IncomingMessage(); + im.headers = { key: 'value' }; + assert.deepStrictEqual(im.headers, { key: 'value' }); +} + +// Trailers setter function set a header correctly +{ + const im = new IncomingMessage(); + im.trailers = { key: 'value' }; + assert.deepStrictEqual(im.trailers, { key: 'value' }); +} + +// _addHeaderLines function set a header correctly +{ + const im = new IncomingMessage(); + im.headers = { key1: 'value1' }; + im._addHeaderLines(['key2', 'value2'], 2); + assert.deepStrictEqual(im.headers, { key1: 'value1', key2: 'value2' }); +}