node-mocks-http
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -41,3 +41,2 @@ 'use strict'; | ||
var _data = ''; | ||
var _headers = {}; | ||
var _encoding = options.encoding; | ||
@@ -62,2 +61,4 @@ | ||
mockResponse._headers = {}; | ||
mockResponse.statusCode = 200; | ||
@@ -106,5 +107,5 @@ mockResponse.cookies = {}; | ||
if (headers) { | ||
_headers = headers; | ||
mockResponse._headers = headers; | ||
} else { | ||
_headers = phrase; | ||
mockResponse._headers = phrase; | ||
} | ||
@@ -175,3 +176,3 @@ | ||
_formatData(a); | ||
_headers = b; | ||
mockResponse._headers = b; | ||
mockResponse.statusCode = c; | ||
@@ -360,3 +361,3 @@ console.warn('WARNING: Called send() with deprecated three parameters'); | ||
mockResponse.get = mockResponse.getHeader = function(name) { | ||
return _headers[name]; | ||
return mockResponse._headers[name]; | ||
}; | ||
@@ -371,3 +372,3 @@ | ||
mockResponse.setHeader = function(name, value) { | ||
_headers[name] = value; | ||
mockResponse._headers[name] = value; | ||
return value; | ||
@@ -382,3 +383,3 @@ }; | ||
mockResponse.removeHeader = function(name) { | ||
delete _headers[name]; | ||
delete mockResponse._headers[name]; | ||
}; | ||
@@ -525,3 +526,3 @@ | ||
mockResponse._getHeaders = function() { | ||
return _headers; | ||
return mockResponse._headers; | ||
}; | ||
@@ -554,3 +555,3 @@ | ||
mockResponse._isJSON = function() { | ||
return (_headers['Content-Type'] === 'application/json'); | ||
return (mockResponse._headers['Content-Type'] === 'application/json'); | ||
}; | ||
@@ -592,4 +593,4 @@ | ||
if (_headers['Content-Length']) { | ||
return (_headers['Content-Length'].toString() === _data.length.toString()); | ||
if (mockResponse._headers['Content-Length']) { | ||
return (mockResponse._headers['Content-Length'].toString() === _data.length.toString()); | ||
} | ||
@@ -596,0 +597,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Mock 'http' objects for testing Express routing functions", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"homepage": "https://github.com/howardabrams/node-mocks-http", | ||
@@ -8,0 +8,0 @@ "bugs": { |
@@ -1,11 +0,11 @@ | ||
[![node-mocks-http logo](https://raw.githubusercontent.com/wiki/howardabrams/node-mocks-http/images/nmh-logo-200x132.png)](https://github.com/howardabrams/node-mocks-http) | ||
[![node-mocks-http logo][nmh-logo]][nmh-url] | ||
--- | ||
[![NPM version](https://badge.fury.io/js/node-mocks-http.png)](https://www.npmjs.com/package/node-mocks-http) | ||
[![Build Status](https://travis-ci.org/howardabrams/node-mocks-http.svg?branch=master)](https://travis-ci.org/howardabrams/node-mocks-http) | ||
[![Gitter chat](https://badges.gitter.im/howardabrams/node-mocks-http.png)](https://gitter.im/howardabrams/node-mocks-http) | ||
[![NPM version][npm-badge]][npm-url] | ||
[![Build Status][travis-badge]][travis-url] | ||
[![Gitter chat][gitter-badge]][gitter-url] | ||
Mock 'http' objects for testing [Express](http://expressjs.com/) | ||
Mock 'http' objects for testing [Express][express-url] | ||
routing functions, but could be used for testing any | ||
[Node.js](http://www.nodejs.org) web server applications that have | ||
[Node.js][node-url] web server applications that have | ||
code that requires mockups of the `request` and `response` objects. | ||
@@ -16,3 +16,3 @@ | ||
This project is available as a | ||
[NPM package](https://www.npmjs.org/package/node-mocks-http). | ||
[NPM package][npm-url]. | ||
@@ -78,2 +78,39 @@ ```bash | ||
## API | ||
### .createRequest() | ||
``` | ||
httpMocks.createRequest(options) | ||
``` | ||
Where options is an object hash with any of the following values: | ||
option | description | default value | ||
------ | ----------- | ------------- | ||
`method`| request HTTP method | 'GET' | ||
`url` | request URL | '' | ||
`originalUrl` | request original URL | `url` | ||
`path` | request path | '' | ||
`params` | object hash with params | {} | ||
`session` | object hash with session values | `undefined` | ||
`cookies` | object hash with request cookies | {} | ||
`signedCookies` | object hash with signed cookies | `undefined` | ||
`headers` | object hash with request headers | {} | ||
`body` | object hash with body | {} | ||
`query` | object hash with query values | {} | ||
`files` | object hash with values | {} | ||
### .createResponse() | ||
```js | ||
httpMocks.createResponse(options) | ||
``` | ||
Where options is an object hash with any of the following values: | ||
option | description | default value | ||
------ | ----------- | ------------- | ||
`eventEmitter` | event emitter used by nmh | `mockEventEmitter` | ||
`writableStream` | writable stream used by nmh | `mockWritableStream` | ||
## Design Decisions | ||
@@ -91,3 +128,3 @@ | ||
including the creation of more objects from the | ||
[HTTP module](http://nodejs.org/docs/latest/api/http.html). | ||
[HTTP module][node-http-module-url]. | ||
@@ -107,10 +144,11 @@ This project doesn't address all features that must be | ||
[Most Recent Release Notes](https://github.com/howardabrams/node-mocks-http/releases) | ||
[Most Recent Release Notes][release-notes] | ||
* [v1.4.1](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.1) - April 14, 2015 | ||
* [v1.4.0](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.0) - April 12, 2015 | ||
* [v1.3.0](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.3.0) - April 5, 2015 | ||
* [v1.2.7](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.7) - March 24, 2015 | ||
* [v1.2.6](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.6) - March 19, 2015 | ||
* [v1.2.5](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.5) - March 5, 2015 | ||
* [v1.4.2][release-v1.4.2] - April 30, 2015 | ||
* [v1.4.1][release-v1.4.1] - April 14, 2015 | ||
* [v1.4.0][release-v1.4.0] - April 12, 2015 | ||
* [v1.3.0][release-v1.3.0] - April 5, 2015 | ||
* [v1.2.7][release-v1.2.7] - March 24, 2015 | ||
* [v1.2.6][release-v1.2.6] - March 19, 2015 | ||
* [v1.2.5][release-v1.2.5] - March 5, 2015 | ||
@@ -122,1 +160,27 @@ | ||
Licensed under [MIT](https://github.com/howardabrams/node-mocks-http/blob/master/LICENSE). | ||
[nmh-logo]: https://raw.githubusercontent.com/wiki/howardabrams/node-mocks-http/images/nmh-logo-200x132.png | ||
[nmh-url]: https://github.com/howardabrams/node-mocks-http | ||
[npm-badge]: https://badge.fury.io/js/node-mocks-http.png | ||
[npm-url]: https://www.npmjs.com/package/node-mocks-http | ||
[travis-badge]: https://travis-ci.org/howardabrams/node-mocks-http.svg?branch=master | ||
[travis-url]: https://travis-ci.org/howardabrams/node-mocks-http | ||
[gitter-badge]: https://badges.gitter.im/howardabrams/node-mocks-http.png | ||
[gitter-url]: https://gitter.im/howardabrams/node-mocks-http | ||
[express-url]: http://expressjs.com/ | ||
[node-url]: http://www.nodejs.org | ||
[node-http-module-url]: http://nodejs.org/docs/latest/api/http.html | ||
[release-notes]: https://github.com/howardabrams/node-mocks-http/releases | ||
[release-v1.4.2]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.2 | ||
[release-v1.4.1]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.1 | ||
[release-v1.4.0]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.0 | ||
[release-v1.3.0]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.3.0 | ||
[release-v1.2.7]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.7 | ||
[release-v1.2.6]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.6 | ||
[release-v1.2.5]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.5 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109672
30
2237
182
1