From e41a5aaa1a08925851d8424f8fe559dbdaa96f4e Mon Sep 17 00:00:00 2001 From: welefen Date: Tue, 26 Aug 2014 06:44:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Http=E7=9A=84=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/Lib/Core/Http.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/test/Lib/Core/Http.js b/test/Lib/Core/Http.js index b4c2b297..9991bcea 100644 --- a/test/Lib/Core/Http.js +++ b/test/Lib/Core/Http.js @@ -135,7 +135,7 @@ describe('Http', function(){ done(); }) }) - it('setCookie', function(){ + it('setCookie', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.setCookie('name', 'welefen'); //console.log(http._cookie) @@ -143,7 +143,7 @@ describe('Http', function(){ done(); }) }) - it('setCookie with timeout', function(){ + it('setCookie with timeout', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.setCookie('name', 'welefen', 10000); //console.log(http._cookie) @@ -152,7 +152,19 @@ describe('Http', function(){ done(); }) }) - it('setCookie, remove cookie', function(){ + it('setCookie with timeout 1', function(done){ + Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ + var opts = {timeout: 20000}; + http.setCookie('name', 'welefen', opts); + http.setCookie('name', 'welefen', opts); + //console.log(http._cookie) + assert.equal(http._cookie.name.expires !== undefined, true); + assert.equal(http._cookie.name.timeout, 20000); + assert.equal(http._cookie.name.expires instanceof Date, true) + done(); + }) + }) + it('setCookie, remove cookie', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.setCookie('name', null); //console.log(http._cookie) @@ -161,14 +173,14 @@ describe('Http', function(){ done(); }) }) - it('setCookie, with options', function(){ + it('setCookie, with options', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.setCookie('name', 'welefen', {path: '/xxx/', Domain: 'welefen.com'}); assert.deepEqual(http._cookie, {"name":{"path":"/xxx/","domain":"welefen.com","name":"name","value":"welefen"}}) done(); }) }) - it('sendCookie', function(){ + it('sendCookie', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.setCookie('name', 'welefen', {path: '/xxx/', Domain: 'welefen.com'}); var fn = http.res.setHeader; @@ -182,13 +194,13 @@ describe('Http', function(){ http.sendCookie(); }) }) - it('sendCookie empty', function(){ + it('sendCookie empty', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.sendCookie(); done(); }) }) - it('sendCookie multi', function(){ + it('sendCookie multi', function(done){ Http(defaultHttp.req, defaultHttp.res).run().then(function(http){ http.setCookie('name', 'welefen', {path: '/xxx/', Domain: 'welefen.com'}); http.setCookie('value', 'suredy');