From 065a773e655df631b2d736d1681f6c04d7963187 Mon Sep 17 00:00:00 2001 From: dead_horse Date: Wed, 1 Oct 2014 20:42:29 +0800 Subject: [PATCH] more test case --- test/response/header.js | 10 +++++++++- test/response/last-modified.js | 9 ++++++++- test/response/writeable.js | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/response/writeable.js diff --git a/test/response/header.js b/test/response/header.js index d75882c..3bf9f3d 100644 --- a/test/response/header.js +++ b/test/response/header.js @@ -7,4 +7,12 @@ describe('res.header', function(){ res.set('X-Foo', 'bar'); res.header.should.eql({ 'x-foo': 'bar' }); }) -}) \ No newline at end of file + + describe('when res._headers not present', function (){ + it('should return empty object', function (){ + var res = response(); + res.res._headers = null; + res.header.should.eql({}); + }) + }) +}) diff --git a/test/response/last-modified.js b/test/response/last-modified.js index dfc6642..0eddad1 100644 --- a/test/response/last-modified.js +++ b/test/response/last-modified.js @@ -24,4 +24,11 @@ describe('res.lastModified', function(){ (res.lastModified.getTime() / 1000) .should.equal(Math.floor(date.getTime() / 1000)); }) -}) \ No newline at end of file + + describe('when lastModified not set', function (){ + it('should get undefined', function(){ + var res = response(); + (res.lastModified === undefined).should.be.ok; + }) + }) +}) diff --git a/test/response/writeable.js b/test/response/writeable.js new file mode 100644 index 0000000..0f58b32 --- /dev/null +++ b/test/response/writeable.js @@ -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; + }) + }) +})