koa-lite/test/response/headers.js

22 lines
532 B
JavaScript
Raw Normal View History

'use strict';
2017-05-11 03:30:32 +00:00
const assert = require('assert');
const response = require('../helpers/context').response;
describe('res.header', () => {
it('should return the response header object', () => {
const res = response();
res.set('X-Foo', 'bar');
2017-05-11 03:30:32 +00:00
assert.deepEqual(res.headers, { 'x-foo': 'bar' });
2015-10-12 20:36:41 +00:00
});
describe('when res._headers not present', () => {
it('should return empty object', () => {
const res = response();
res.res._headers = null;
2017-05-11 03:30:32 +00:00
assert.deepEqual(res.headers, {});
2015-10-12 20:36:41 +00:00
});
});
});