test: http outgoing _renderHeaders
PR-URL: https://github.com/nodejs/node/pull/13981 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
2288e3f21c
commit
074b7c271c
46
test/parallel/test-http-outgoing-renderHeaders.js
Normal file
46
test/parallel/test-http-outgoing-renderHeaders.js
Normal file
@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
// Flags: --expose-internals
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const outHeadersKey = require('internal/http').outHeadersKey;
|
||||
const http = require('http');
|
||||
const OutgoingMessage = http.OutgoingMessage;
|
||||
|
||||
{
|
||||
const outgoingMessage = new OutgoingMessage();
|
||||
outgoingMessage._header = {};
|
||||
assert.throws(
|
||||
outgoingMessage._renderHeaders.bind(outgoingMessage),
|
||||
/^Error: Can't render headers after they are sent to the client$/
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const outgoingMessage = new OutgoingMessage();
|
||||
outgoingMessage[outHeadersKey] = null;
|
||||
const result = outgoingMessage._renderHeaders();
|
||||
assert.deepStrictEqual(result, {});
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const outgoingMessage = new OutgoingMessage();
|
||||
outgoingMessage[outHeadersKey] = {};
|
||||
const result = outgoingMessage._renderHeaders();
|
||||
assert.deepStrictEqual(result, {});
|
||||
}
|
||||
|
||||
{
|
||||
const outgoingMessage = new OutgoingMessage();
|
||||
outgoingMessage[outHeadersKey] = {
|
||||
host: ['host', 'nodejs.org'],
|
||||
origin: ['Origin', 'localhost']
|
||||
};
|
||||
const result = outgoingMessage._renderHeaders();
|
||||
assert.deepStrictEqual(result, {
|
||||
host: 'nodejs.org',
|
||||
Origin: 'localhost'
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user