initial release
[squeep-api-dingus] / test / lib / patches / incoming-message.js
1 /* eslint-disable capitalized-comments */
2 /* eslint-env mocha */
3 'use strict';
4
5 const assert = require('assert');
6 const { IncomingMessage } = require('http');
7 require('../../../lib/patches/incoming-message');
8
9 describe('IncomingMessage.getHeader', function () {
10 let im;
11 beforeEach(function () {
12 im = new IncomingMessage();
13 });
14 it('requires string arg', function () {
15 try {
16 im.getHeader(1);
17 assert.fail('did not get expected exception');
18 } catch (e) {
19 assert.strictEqual(e.name, 'TypeError');
20 }
21 });
22 it('is callable', function () {
23 const name = 'x-header';
24 const value = undefined;
25 const result = im.getHeader(name);
26 assert.strictEqual(result, value);
27 });
28 it('returns a header', function () {
29 const name = 'x-header';
30 const value = 'foo';
31 // eslint-disable-next-line security/detect-object-injection
32 im.headers[name] = value;
33 const result = im.getHeader(name);
34 assert.strictEqual(result, value);
35 });
36 });
37