Socket
Socket
Sign inDemoInstall

node-mocks-http

Package Overview
Dependencies
0
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 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({

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc