From 0192d21d737e89367998cc5cf60b126a86eeb10c Mon Sep 17 00:00:00 2001 From: Bryan Bess Date: Fri, 2 Oct 2015 19:18:05 -0500 Subject: [PATCH] Increase test coverage --- test/request/ip.js | 7 +++++++ test/request/querystring.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/request/ip.js b/test/request/ip.js index 405b83c..9758a80 100644 --- a/test/request/ip.js +++ b/test/request/ip.js @@ -18,5 +18,12 @@ describe('req.ip', function(){ req.socket.remoteAddress = '127.0.0.2'; req.ip.should.equal('127.0.0.2'); }) + describe('with req.socket.remoteAddress not present', function() { + it('should return an empty string', function(){ + var req = request(); + req.socket.remoteAddress = null; + req.ip.should.equal(''); + }) + }) }) }) diff --git a/test/request/querystring.js b/test/request/querystring.js index ce45577..59e9387 100644 --- a/test/request/querystring.js +++ b/test/request/querystring.js @@ -1,6 +1,20 @@ var context = require('../context'); +describe('ctx.querystring', function(){ + it('should return the querystring', function () { + var ctx = context({ url: '/store/shoes?page=2&color=blue' }); + ctx.querystring.should.equal('page=2&color=blue'); + }) + describe('when ctx.req not present', function() { + it('should return an empty string', function (){ + var ctx = context(); + ctx.request.req = null; + ctx.querystring.should.equal(''); + }) + }) +}) + describe('ctx.querystring=', function(){ it('should replace the querystring', function(){ var ctx = context({ url: '/store/shoes' });