Socket
Socket
Sign inDemoInstall

node-mocks-http

Package Overview
Dependencies
14
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.6 to 1.6.7

15

HISTORY.md

@@ -0,1 +1,16 @@

v 1.6.7
-------
- Set an expiration date to a cookie when deleting it [#155][115]
- No `finish` event, `end` event called when it shouldn't be. [#112][112]
- Add support for [append][] on MockResponse [#143][143]
Special shoutout to [Eugene Fidelin](https://github.com/eugef) for
joining the team and helping out so much.
[112]: https://github.com/howardabrams/node-mocks-http/issues/112
[143]: https://github.com/howardabrams/node-mocks-http/issues/143
[155]: https://github.com/howardabrams/node-mocks-http/issues/155
[append]: http://expressjs.com/en/api.html#res.append
v 1.6.6

@@ -2,0 +17,0 @@ -------

12

lib/express/mock-express.js

@@ -11,14 +11,4 @@ 'use strict';

function createExpressResponse(options) {
var res = response.createResponse(options);
// http://expressjs.com/en/api.html#res.locals
res.locals = options && options.locals || {};
return res;
}
var expressResponse = {
createResponse: createExpressResponse
createResponse: response.createResponse
};

@@ -25,0 +15,0 @@

@@ -69,2 +69,5 @@ 'use strict';

// http://expressjs.com/en/api.html#res.locals
mockResponse.locals = options.locals || {};
mockResponse.cookie = function(name, value, opt) {

@@ -80,5 +83,8 @@

mockResponse.clearCookie = function(name) {
delete mockResponse.cookies[name];
return this;
mockResponse.clearCookie = function(name, opt) {
var opts = opt || {};
opts.expires = new Date(1);
opts.path = '/';
return this.cookie(name, '', opts);
};

@@ -436,2 +442,30 @@

/**
* Append additional header `field` with value `val`.
*
* Example:
*
* res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
* res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
* res.append('Warning', '199 Miscellaneous warning');
*
* @param {String} field
* @param {String|Array} val
* @return {ServerResponse} for chaining
* @api public
*/
mockResponse.append = function append(field, val) {
var prev = mockResponse.get(field);
var value = val;
if (prev) {
// concat the new and prev vals
value = Array.isArray(prev) ? prev.concat(val)
: Array.isArray(val) ? [prev].concat(val)
: [prev, val];
}
return mockResponse.set(field, value);
};
/**
* Set header `field` to `val`, or pass

@@ -438,0 +472,0 @@ * an object of header fields.

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

"description": "Mock 'http' objects for testing Express routing functions",
"version": "1.6.6",
"version": "1.6.7",
"homepage": "https://github.com/howardabrams/node-mocks-http",

@@ -57,3 +57,3 @@ "bugs": {

"devDependencies": {
"@types/express": "^4.0.35",
"@types/express": "^4.11.0",
"chai": "^3.5.0",

@@ -60,0 +60,0 @@ "eslint": "^3.13.1",

@@ -112,2 +112,3 @@ [![node-mocks-http logo][nmh-logo]][nmh-url]

------ | ----------- | -------------
`locals` | object that contains `response` local variables | `{}`
`eventEmitter` | event emitter used by `response` object | `mockEventEmitter`

@@ -114,0 +115,0 @@ `writableStream` | writable stream used by `response` object | `mockWritableStream`

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