Skip to content

Commit

Permalink
Add a test for appendHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarkebm committed Sep 9, 2024
1 parent 0d5ca94 commit e943993
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/lib/mockResponse.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ describe('mockResponse', () => {
expect(response).to.have.property('setHeader');
expect(response.setHeader).to.be.a('function');

expect(response).to.have.property('appendHeader');
expect(response.appendHeader).to.be.a('function');

expect(response).to.have.property('removeHeader');
expect(response.removeHeader).to.be.a('function');

Expand Down Expand Up @@ -924,8 +927,8 @@ describe('mockResponse', () => {
});
});

// TODO: fix in 2.0; methods should be inherited from Node OutogingMessage
describe('Node OutogingMessage methods', () => {
// TODO: fix in 2.0; methods should be inherited from Node OutgoingMessage
describe('Node OutgoingMessage methods', () => {
describe('.setHeader()', () => {
let response;

Expand All @@ -951,6 +954,24 @@ describe('mockResponse', () => {
});
});

describe('.appendHeader()', () => {
let response;

beforeEach(() => {
response = mockResponse.createResponse();
});

afterEach(() => {
response = null;
});

it('should concatenate header values, when called twice with same name', () => {
response.appendHeader('name', 'value 1');
response.appendHeader('name', 'value 2');
expect(response.getHeader('name')).to.eql(['value 1', 'value 2']);
});
});

describe('.getHeader()', () => {
let response;

Expand Down

0 comments on commit e943993

Please sign in to comment.