more test case

This commit is contained in:
dead_horse 2014-10-01 20:42:29 +08:00
parent 8774979e13
commit 065a773e65
3 changed files with 34 additions and 2 deletions

View file

@ -7,4 +7,12 @@ describe('res.header', function(){
res.set('X-Foo', 'bar'); res.set('X-Foo', 'bar');
res.header.should.eql({ 'x-foo': 'bar' }); res.header.should.eql({ 'x-foo': 'bar' });
}) })
describe('when res._headers not present', function (){
it('should return empty object', function (){
var res = response();
res.res._headers = null;
res.header.should.eql({});
})
})
}) })

View file

@ -24,4 +24,11 @@ describe('res.lastModified', function(){
(res.lastModified.getTime() / 1000) (res.lastModified.getTime() / 1000)
.should.equal(Math.floor(date.getTime() / 1000)); .should.equal(Math.floor(date.getTime() / 1000));
}) })
describe('when lastModified not set', function (){
it('should get undefined', function(){
var res = response();
(res.lastModified === undefined).should.be.ok;
})
})
}) })

View file

@ -0,0 +1,17 @@
var response = require('../context').response;
describe('res.writable', function(){
it('should return the request is writable', function(){
var res = response();
res.writable.should.be.ok;
})
describe('when res.socket not present', function (){
it('should return the request is not writable', function (){
var res = response();
res.res.socket = null;
res.writable.should.not.be.ok;
})
})
})