🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

node-mocks-http

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-mocks-http - npm Package Compare versions

Comparing version

to
1.2.3

examples/express-status-vs-json.js

16

lib/mockRequest.js

@@ -79,12 +79,14 @@ 'use strict';

mockRequest.param = function(parameterName) {
if (mockRequest.params[parameterName])
if (mockRequest.params[parameterName]) {
return mockRequest.params[parameterName];
if (mockRequest.body[parameterName])
}
else if (mockRequest.body[parameterName]) {
return mockRequest.body[parameterName];
if (mockRequest.query[parameterName])
}
else if (mockRequest.query[parameterName]) {
return mockRequest.query[parameterName];
return null;
}
else {
return null;
}
};

@@ -91,0 +93,0 @@

@@ -197,3 +197,6 @@ 'use strict';

mockResponse.setHeader('Content-Type', 'application/json');
mockResponse.statusCode = 200;
// Sets default status code if none has been specify.
if(mockResponse.statusCode === -1) {
mockResponse.statusCode = 200;
}

@@ -200,0 +203,0 @@ if (a) {

@@ -5,3 +5,3 @@ {

"description": "Mock 'http' objects for testing Express routing functions",
"version": "1.2.2",
"version": "1.2.3",
"homepage": "http://www.github.com/howardabrams/node-mocks-http",

@@ -8,0 +8,0 @@ "license" : "MIT",

@@ -288,2 +288,14 @@ /**

exports['json - With status code - chain'] = function (test) {
var response = httpMocks.createResponse(),
data = {
hello: 'there'
};
response.status(201).json(data);
test.equal(response._isJSON(), true);
test.equal(response._getData(), JSON.stringify(data));
test.equal(response.statusCode, 201);
test.done();
};
exports['events - end'] = function (test) {

@@ -290,0 +302,0 @@ var response = httpMocks.createResponse({