[Pkg-javascript-commits] [node-mocks-http] 70/296: added test case for req.path which mocks express 'http://expressjs.com/4x/api.html#req.path'

Thorsten Alteholz alteholz at moszumanska.debian.org
Mon Feb 8 18:13:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

alteholz pushed a commit to branch master
in repository node-mocks-http.

commit a440aa19fc0d883f7da29db32e7458d19c3dfb6d
Author: Kishore varma <kishore.varma at myntra.com>
Date:   Tue Jan 20 11:39:11 2015 +0530

    added test case for req.path which mocks express 'http://expressjs.com/4x/api.html#req.path'
---
 lib/mockRequest.js       |  4 ++--
 test/test-mockRequest.js | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/mockRequest.js b/lib/mockRequest.js
index 947e586..96d3360 100644
--- a/lib/mockRequest.js
+++ b/lib/mockRequest.js
@@ -52,8 +52,8 @@ function createRequest(options) {
     mockRequest.files = (options.files) ? options.files : {};
 
     //parse query string from url to object
-    if (Object.keys(mockRequest.query).length == 0) {
-        mockRequest.query = require('querystring').parse(mockRequest.url.split('?')[1])
+    if (Object.keys(mockRequest.query).length === 0) {
+        mockRequest.query = require('querystring').parse(mockRequest.url.split('?')[1]);
     }
 
     /**
diff --git a/test/test-mockRequest.js b/test/test-mockRequest.js
index e437cd1..f3ce196 100644
--- a/test/test-mockRequest.js
+++ b/test/test-mockRequest.js
@@ -196,3 +196,13 @@ exports['query object is parsed from supplied options if provided'] = function(t
 
     test.done();
 };
+
+exports['path(pathname) has to be parsed from url'] = function(test) {
+    var request = httpMocks.createRequest({
+        url: 'http://www.whatever.com/iamthepath?a=1&b=2&c=3'
+    });
+
+    test.equal(request.path, 'iamthepath');
+
+    test.done();
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git



More information about the Pkg-javascript-commits mailing list