koa-lite/test/response/header.js

31 lines
740 B
JavaScript
Raw Normal View History

'use strict';
var response = require('../context').response;
describe('res.header', function(){
it('should return the response header object', function(){
var res = response();
res.set('X-Foo', 'bar');
res.header.should.eql({ 'x-foo': 'bar' });
})
2014-10-01 12:42:29 +00:00
it('should use res.getHeaders helper when it is available', function(){
var res = response(null, {
_headers: {},
getHeaders: function(){
return { 'x-foo': 'baz' }
}
});
res.header.should.eql({ 'x-foo': 'baz' });
})
2014-10-01 12:42:29 +00:00
describe('when res._headers not present', function (){
it('should return empty object', function (){
var res = response();
res.res._headers = null;
res.header.should.eql({});
})
})
})