Skip to content

Commit

Permalink
Merge branch 'release/1.4' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Estilles committed Apr 11, 2015
2 parents 1c85031 + e6559c5 commit aeb7274
Show file tree
Hide file tree
Showing 17 changed files with 1,659 additions and 791 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.project
.settings
coverage
node_modules
test/results
npm-debug.log
15 changes: 14 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ node_js:
- "0.12"

notifications:
email:
email:
- "[email protected]"
- "[email protected]"

addons:
code_climate:
repo_token: 75dc20817d25bb52614e495f87d69b228edac0016fb096ccab2a75b624c68d4e

before_script:
- npm install -g gulp
- npm install -g codeclimate-test-reporter
- gulp lint

after_script:
- gulp coverage
- codeclimate < ./coverage/lcov.info
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ by Express.

[Most Recent Releast Notes](https://github.com/howardabrams/node-mocks-http/releases)

* [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
Expand Down
44 changes: 44 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var eslint = require('gulp-eslint');

var files = {
src: ['./lib/**/*.js'],
test: ['./test/**/*.spec.js']
};

gulp.task('lint', function () {
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'}));
});

gulp.task('spec', function () {
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);
});
});
10 changes: 4 additions & 6 deletions lib/mockResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,6 @@ function createResponse(options) {
switch (arguments.length) {

case 2:
break;

case 3:
_renderData = b;
break;

Expand All @@ -449,9 +446,10 @@ function createResponse(options) {

};

mockResponse.writable = function() {
return writableStream.writable.apply(this, arguments);
};
// WritableStream.writable is not a function
// mockResponse.writable = function() {
// return writableStream.writable.apply(this, arguments);
// };

// mockResponse.end = function(){
// return writableStream.end.apply(this, arguments);
Expand Down
9 changes: 8 additions & 1 deletion lib/mockWritableStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@

function WritableStream() {}

WritableStream.prototype.writable = function () {};
Object.defineProperty(WritableStream, 'writable', {
configurable: true,
enumerable: true,
get: function() {
return true;
}
});

// WritableStream.prototype.write = function(string, [encoding], [fd]){}
// WritableStream.prototype.write = function(buffer){}
WritableStream.prototype.end = function () {};
Expand Down
31 changes: 19 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"author": "Howard Abrams <[email protected]> (http://www.github.com/howardabrams)",
"name": "node-mocks-http",
"description": "Mock 'http' objects for testing Express routing functions",
"version": "1.3.0",
"version": "1.4.0",
"homepage": "https://github.com/howardabrams/node-mocks-http",
"bugs": {
"url" : "https://github.com/howardabrams/node-mocks-http/issues"
"url": "https://github.com/howardabrams/node-mocks-http/issues"
},
"contributors": [
{
"name" : "Howard Abrams",
"email" : "[email protected]",
"url" : "https://github.com/howardabrams"
"name": "Howard Abrams",
"email": "[email protected]",
"url": "https://github.com/howardabrams"
},
{
"name" : "Johnny Estilles",
"email" : "[email protected]",
"url" : "https://github.com/JohnnyEstilles"
"name": "Johnny Estilles",
"email": "[email protected]",
"url": "https://github.com/JohnnyEstilles"
}
],
"license": "MIT",
Expand All @@ -43,12 +43,19 @@
"mime": "^1.3.4"
},
"devDependencies": {
"chai": "^2.2.0",
"eslint": "^0.18.0",
"node-restify-errors": "git://github.com/m9dfukc/node-restify-errors.git",
"nodeunit": "^0.9.1"
"eslint-plugin-mocha": "^0.2.2",
"gulp": "^3.8.11",
"gulp-eslint": "^0.8.0",
"gulp-istanbul": "^0.8.1",
"gulp-mocha": "^2.0.1",
"istanbul": "^0.3.13",
"mocha": "^2.2.4",
"sinon": "^1.14.1",
"sinon-chai": "^2.7.0"
},
"scripts": {
"lint": "DEBUG=eslint:cli-engine node_modules/eslint/bin/eslint.js ./lib ./examples ./test",
"test": "npm run lint && ./run-tests"
"test": "gulp spec"
}
}
11 changes: 0 additions & 11 deletions run-tests

This file was deleted.

88 changes: 88 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"env": {
"node": true
},

"plugins": ["mocha"],

"globals": {
"describe": 1,
"it": 1,
"before": 1,
"beforeEach": 1,
"after": 1,
"afterEach": 1
},

"rules": {
"mocha/no-exclusive-tests": 2,
"comma-dangle": 2,
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-div-regex": 2,
"no-dupe-keys": 2,
"no-else-return": 2,
"no-empty": 2,
"no-empty-class": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-func-assign": 0,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-with": 2,
"no-fallthrough": 2,
"no-unreachable": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-unused-expressions": 0,
"no-octal": 2,
"no-octal-escape": 2,
"no-obj-calls": 2,
"no-multi-str": 2,
"no-new-wrappers": 2,
"no-new": 2,
"no-new-func": 2,
"no-native-reassign": 2,
"no-delete-var": 2,
"no-return-assign": 2,
"no-new-object": 2,
"no-label-var": 2,
"no-self-compare": 2,
"no-sync": 2,
"no-loop-func": 2,
"no-empty-label": 2,
"no-unused-vars": 1,
"no-script-url": 2,
"no-proto": 2,
"no-iterator": 2,
"no-mixed-requires": [0, false],
"no-wrap-func": 2,
"no-shadow": 2,
"no-use-before-define": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-mixed-spaces-and-tabs": 2,
"no-underscore-dangle": 0,

"brace-style": 2,
"camelcase": 2,
"consistent-this": [2, "self"],
"curly": 2,
"dot-notation": 2,
"eqeqeq": 2,
"new-cap": 2,
"new-parens": 2,
"quotes": [2, "single"],
"semi": 2,
"strict": [2, "global"],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": 2,
"indent": [2, 2, {"indentSwitchCase": true}]
}
}
21 changes: 21 additions & 0 deletions test/lib/http-mock.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var chai = require('chai');
var expect = chai.expect;

var httpMock;

describe('http-mock', function() {
before(function() {
httpMock = require('../../lib/http-mock');
});

it('should export .createRequest()', function() {
expect(httpMock.createRequest).to.be.a('function');
});

it('should export .createResponse()', function() {
expect(httpMock.createResponse).to.be.a('function');
});

});
61 changes: 61 additions & 0 deletions test/lib/mockEventEmitter.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

var chai = require('chai');
var expect = chai.expect;

var MockEventEmitter = require('../../lib/mockEventEmitter');
var mockEventEmitter;

describe('mockEventEmitter', function() {

before(function() {
mockEventEmitter = new MockEventEmitter();
});

it('should be a function', function() {
expect(MockEventEmitter).to.be.a('function');
});

it('should be an object factory', function() {
expect(mockEventEmitter).to.be.a('object');
expect(mockEventEmitter).to.be.an.instanceof(MockEventEmitter);
});

it('should expose "MockEventEmitter" prototype', function() {
expect(mockEventEmitter).to.have.property('addListener');
expect(mockEventEmitter.addListener).to.be.a('function');

expect(mockEventEmitter).to.have.property('on');
expect(mockEventEmitter.on).to.be.a('function');

expect(mockEventEmitter).to.have.property('once');
expect(mockEventEmitter.once).to.be.a('function');

expect(mockEventEmitter).to.have.property('removeListener');
expect(mockEventEmitter.removeListener).to.be.a('function');

expect(mockEventEmitter).to.have.property('removeAllListeners');
expect(mockEventEmitter.removeAllListeners).to.be.a('function');

expect(mockEventEmitter).to.have.property('setMaxListeners');
expect(mockEventEmitter.setMaxListeners).to.be.a('function');

expect(mockEventEmitter).to.have.property('listeners');
expect(mockEventEmitter.listeners).to.be.a('function');

expect(mockEventEmitter).to.have.property('emit');
expect(mockEventEmitter.emit).to.be.a('function');
});

it('should return undefined when methods called', function() {
expect(mockEventEmitter.addListener()).to.be.undefined;
expect(mockEventEmitter.on()).to.be.undefined;
expect(mockEventEmitter.once()).to.be.undefined;
expect(mockEventEmitter.removeListener()).to.be.undefined;
expect(mockEventEmitter.removeAllListeners()).to.be.undefined;
expect(mockEventEmitter.setMaxListeners()).to.be.undefined;
expect(mockEventEmitter.listeners()).to.be.undefined;
expect(mockEventEmitter.emit()).to.be.undefined;
});

});
Loading

0 comments on commit aeb7274

Please sign in to comment.