Skip to content

Commit

Permalink
Add travis-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
DremyGit committed Jun 8, 2016
1 parent 56c6843 commit bad579f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/coverage
/.idea
*.log
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sudo: false

language: node_js

node_js:
- 0.10
- 4
- 5
- iojs

after_success: npm install coveralls mocha-lcov-reporter && NODE_ENV=test ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- --recursive -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "some-http-error",
"version": "0.0.2",
"version": "0.1.0",
"description": "A javascript error creator for some often used HTTP error",
"main": "index.js",
"scripts": {
"test": "mocha test.js",
"test:watch": "mocha --watch test.js"
"test:watch": "mocha --watch test.js",
"coverage": "NODE_ENV=test istanbul cover _mocha -- --recursive"
},
"repository": {
"type": "git",
Expand All @@ -23,6 +24,7 @@
"homepage": "https://github.com/DremyGit/some-http-error#readme",
"devDependencies": {
"chai": "^3.5.0",
"istanbul": "^0.4.3",
"mocha": "^2.5.3"
}
}
2 changes: 1 addition & 1 deletion some-http-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ HttpError.UnauthorizedError = function (message) {

HttpError.ForbiddenError = function (message) {
message = message || 'Forbidden';
HttpError.call(this, 403, 'ForBiddenError', message);
HttpError.call(this, 403, 'ForbiddenError', message);
};

HttpError.NotFoundError = function (message) {
Expand Down
58 changes: 57 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,49 @@ describe('HttpError', function () {
});
});

describe('SomeError', function () {
describe('BadRequestError', function () {
it('is an instance of Error', function () {
expect(new HttpError.BadRequestError).to.be.an.instanceof(Error);
});
it('is an instance of HttpError', function () {
expect(new HttpError.BadRequestError).to.be.an.instanceof(HttpError)
});
it('has right prototype', function () {
var badRequestError = new HttpError.BadRequestError();
expect(badRequestError.message).to.equal('Bad Request');
expect(badRequestError.name).to.equal('BadRequestError');
expect(badRequestError.statusCode).to.equal(400);
})
});
describe('UnauthorizedError', function () {
it('is an instance of Error', function () {
expect(new HttpError.UnauthorizedError).to.be.an.instanceof(Error);
});
it('is an instance of HttpError', function () {
expect(new HttpError.UnauthorizedError).to.be.an.instanceof(HttpError)
});
it('has right prototype', function () {
var unauthorizedError = new HttpError.UnauthorizedError();
expect(unauthorizedError.message).to.equal('Unauthorized');
expect(unauthorizedError.name).to.equal('UnauthorizedError');
expect(unauthorizedError.statusCode).to.equal(401);
})
});
describe('ForbiddenError', function () {
it('is an instance of Error', function () {
expect(new HttpError.ForbiddenError).to.be.an.instanceof(Error);
});
it('is an instance of HttpError', function () {
expect(new HttpError.ForbiddenError).to.be.an.instanceof(HttpError)
});
it('has right prototype', function () {
var forbiddenError = new HttpError.ForbiddenError();
expect(forbiddenError.message).to.equal('Forbidden');
expect(forbiddenError.name).to.equal('ForbiddenError');
expect(forbiddenError.statusCode).to.equal(403);
})
});
describe('NotFoundError', function () {
it('is an instance of Error', function () {
expect(new HttpError.NotFoundError).to.be.an.instanceof(Error);
});
Expand All @@ -21,3 +63,17 @@ describe('SomeError', function () {
expect(notFoundError.statusCode).to.equal(404);
})
});
describe('MethodNotAllowedError', function () {
it('is an instance of Error', function () {
expect(new HttpError.MethodNotAllowedError).to.be.an.instanceof(Error);
});
it('is an instance of HttpError', function () {
expect(new HttpError.MethodNotAllowedError).to.be.an.instanceof(HttpError)
});
it('has right prototype', function () {
var methodNotAllowedError = new HttpError.MethodNotAllowedError();
expect(methodNotAllowedError.message).to.equal('Method Not Allowed');
expect(methodNotAllowedError.name).to.equal('MethodNotAllowedError');
expect(methodNotAllowedError.statusCode).to.equal(405);
})
});

0 comments on commit bad579f

Please sign in to comment.