2013-11-13 17:01:15 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2013-11-14 02:34:15 +00:00
|
|
|
var response = require('../context').response;
|
2013-11-13 17:01:15 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2017-02-21 06:52:57 +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({});
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|