New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-mocks-http

Package Overview
Dependencies
Maintainers
4
Versions
65
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 1.4.3 to 1.4.4

lib/express/.eslintrc

8

CONTRIBUTING.md

@@ -13,2 +13,8 @@ # Contributing

> **NOTE**
> While we complete our transition to version `2.0`, please adhere to the following:
- For any contributions to our `2.0` track, please create a topic branch based off our `master` branch, push said topic branch onto your fork and submit your pull request from that branch.
- Anyone wishing to contribute a bug fix to our `1.x` track, please create a topic branch based off our `1.x` branch, push said topic branch onto your fork and submit your pull request from that branch..
## <a name="coc"></a> Code of Conduct

@@ -40,3 +46,3 @@ We want to keep our project open and inclusive. We ask that before you

If you believe your issue is a bug, and you can't find a issue in the [archive][issues-archive], just open a new issue.
If you believe your issue is a bug, and you can't find a issue in the [archive][issues-archive], just open a new issue.

@@ -43,0 +49,0 @@ **Help us help you!**

42

gulpfile.js

@@ -14,32 +14,32 @@ 'use strict';

gulp.task('lint', function () {
return gulp.src(files.src.concat(files.test))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
return gulp.src(files.src.concat(files.test))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('test', function () {
return gulp.src(files.test, {read: false})
.pipe(mocha({reporter: 'dot'}));
return gulp.src(files.test, {read: false})
.pipe(mocha({reporter: 'dot'}));
});
gulp.task('spec', function () {
return gulp.src(files.test, {read: false})
.pipe(mocha({reporter: 'spec'}));
return gulp.src(files.test, {read: false})
.pipe(mocha({reporter: 'spec'}));
});
gulp.task('coverage', function (done) {
gulp.src(files.src)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(files.test)
.pipe(mocha({reporter: 'dot'}))
.pipe(istanbul.writeReports({
dir: './coverage',
reporters: ['lcov', 'json', 'html'],
reportOpts: { dir: './coverage' }
}))
.on('end', done);
});
gulp.src(files.src)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(files.test)
.pipe(mocha({reporter: 'dot'}))
.pipe(istanbul.writeReports({
dir: './coverage',
reporters: ['lcov', 'json', 'html'],
reportOpts: { dir: './coverage' }
}))
.on('end', done);
});
});

@@ -0,1 +1,15 @@

v 1.4.4
---
Bug fix release, including the following:
* Fixed for [#67][67]
* Merge fix for [#68][68]
* Merge fix for [#70][70]
* Merge fix for [#73][73]
[67]: https://github.com/howardabrams/node-mocks-http/issues/67
[68]: https://github.com/howardabrams/node-mocks-http/issues/68
[70]: https://github.com/howardabrams/node-mocks-http/issues/70
[73]: https://github.com/howardabrams/node-mocks-http/issues/73
v 1.2.0

@@ -90,2 +104,2 @@ ---

* Initial code banged out one late night...
* Initial code banged out one late night...

@@ -33,2 +33,3 @@ 'use strict';

var url = require('url');
var typeis = require('type-is');

@@ -54,5 +55,6 @@ function convertKeysToLowerCase(map) {

mockRequest.method = (options.method) ? options.method : 'GET';
mockRequest.url = (options.url) ? options.url : '';
mockRequest.url = options.url || options.path || '';
mockRequest.originalUrl = options.originalUrl || mockRequest.url;
mockRequest.path = (options.url) ? url.parse(options.url).pathname : '';
mockRequest.path = options.path ||
(( (options.url) ? url.parse(options.url).pathname : '' ));
mockRequest.params = (options.params) ? options.params : {};

@@ -113,2 +115,34 @@ if (options.session) {

/**
* Function: is
*
* Checks for matching content types in the content-type header.
* Requires a request body, identified by transfer-encoding or content-length headers
*
* Examples:
*
* mockRequest.headers['content-type'] = 'text/html';
* mockRequest.headers['transfer-encoding'] = 'chunked';
* mockRequest.headers['content-length'] = '100';
*
* mockRequest.is('html');
* // => "html"
*
* mockRequest.is('json');
* // => false
*
* mockRequest.is(['json', 'html', 'text']);
* // => "html"
*
* @param {String|String[]} types content type or array of types to match
* @return {String|false|null} Matching content type as string, false if no match, null if request has no body.
* @api public
*/
mockRequest.is = function(types) {
if (!Array.isArray(types)) {
types = [].slice.call(arguments);
}
return typeis(mockRequest, types);
};
/**
* Function: param

@@ -115,0 +149,0 @@ *

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

exports.IncomingMessage = require('./_http_incoming').IncomingMessage;
exports.STATUS_CODES = server.STATUS_CODES;

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

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

@@ -44,3 +44,4 @@ "bugs": {

"dependencies": {
"mime": "^1.3.4"
"mime": "^1.3.4",
"type-is": "^1.6.4"
},

@@ -47,0 +48,0 @@ "devDependencies": {

@@ -111,5 +111,27 @@ [![node-mocks-http logo][nmh-logo]][nmh-url]

------ | ----------- | -------------
`eventEmitter` | event emitter used by nmh | `mockEventEmitter`
`writableStream` | writable stream used by nmh | `mockWritableStream`
`eventEmitter` | event emitter used by `response` object | `mockEventEmitter`
`writableStream` | writable stream used by `response` object | `mockWritableStream`
> NOTE: The out-of-the-box mock event emitter included with `node-mocks-http` is
not a functional event emitter and as such does not actually emit events. If you
wish to test your event handlers you will need to bring your own event emitter.
> Here's an example:
```js
var httpMocks = require('node-mocks-http');
var res = httpMocks.createResponse({
EventEmitter: require('events').EventEmitter
});
// ...
it('should do something', funciton(done) {
res.on('end', function() {
assert.equal(...);
done();
});
});
// ...
```
## Design Decisions

@@ -144,2 +166,3 @@

* [v1.4.4][release-v1.4.4] - June 3, 2015
* [v1.4.3][release-v1.4.3] - June 3, 2015

@@ -178,2 +201,3 @@ * [v1.4.2][release-v1.4.2] - April 30, 2015

[release-v1.4.4]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.4
[release-v1.4.3]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.3

@@ -180,0 +204,0 @@ [release-v1.4.2]: https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.2

@@ -82,2 +82,13 @@ 'use strict';

it('should set .url automatically', function() {
var options = {
path: '/this/is/a/path'
};
var expectedUrl = '/this/is/a/path';
request = mockRequest.createRequest(options);
expect(request.url).to.equal(expectedUrl);
});
it('should set .originalUrl to options.originalUrl', function() {

@@ -92,2 +103,11 @@ var options = {

it('should set .path to options.path', function() {
var options = {
path: '/this/is/a/path'
};
request = mockRequest.createRequest(options);
expect(request.path).to.equal(options.path);
});
it('should set .path to pathname of options.url', function() {

@@ -277,2 +297,47 @@ var options = {

describe('.is()', function() {
var request;
afterEach(function() {
request = null;
});
it('should return type, when found in content-type header', function() {
var options = {
headers: {
'content-type': 'text/html',
'transfer-encoding': 'chunked'
}
};
request = mockRequest.createRequest(options);
expect(request.is('html')).to.equal('html');
});
it('should return first matching type, given array of types', function() {
var options = {
headers: {
'content-type': 'text/html',
'transfer-encoding': 'chunked'
}
};
request = mockRequest.createRequest(options);
expect(request.is(['json', 'html', 'text'])).to.equal('html');
});
it('should return false when type not found', function() {
var options = {
headers: {
'content-type': 'text/html',
'transfer-encoding': 'chunked'
}
};
request = mockRequest.createRequest(options);
expect(request.is(['json'])).to.equal(false);
});
});
describe('.param()', function() {

@@ -279,0 +344,0 @@ var request;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc