diff --git a/test/parallel/test-http-outgoing-internal-headers.js b/test/parallel/test-http-outgoing-internal-headers.js new file mode 100644 index 00000000000000..e36917a970d987 --- /dev/null +++ b/test/parallel/test-http-outgoing-internal-headers.js @@ -0,0 +1,28 @@ +// Flags: --expose-internals +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +const { outHeadersKey } = require('internal/http'); +const { OutgoingMessage } = require('http'); + +{ + // tests for _headers get method + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.getHeaders = common.mustCall(); + outgoingMessage._headers; +} + +{ + // tests for _headers set method + const outgoingMessage = new OutgoingMessage(); + outgoingMessage._headers = { + host: 'risingstack.com', + Origin: 'localhost' + }; + + assert.deepStrictEqual(outgoingMessage[outHeadersKey], { + host: ['host', 'risingstack.com'], + origin: ['Origin', 'localhost'] + }); +}