Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
adding test for 400 error with data
Browse files Browse the repository at this point in the history
  • Loading branch information
ekryski committed Feb 24, 2016
1 parent 7bcea97 commit b8d84c3
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions test/error-handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ describe('feathers-errors', () => {

next(e);
})
.get('/bad-request', function(req, res, next) {
next(new errors.BadRequest({
message: 'Invalid Password',
errors: [{
path: 'password',
value: null,
message: `'password' cannot be 'null'`
}]
}));
})
.use(function(req, res, next) {
next(new errors.NotFound('File not found'));
})
Expand Down Expand Up @@ -92,7 +102,7 @@ describe('feathers-errors', () => {
});

describe('application/json format', () => {
it('404', done => {
it('500', done => {
request({
url: 'http://localhost:5050/error',
json: true
Expand All @@ -110,7 +120,7 @@ describe('feathers-errors', () => {
});
});

it('500', done => {
it('404', done => {
request({
url: 'http://localhost:5050/path/to/nowhere',
json: true
Expand All @@ -125,6 +135,29 @@ describe('feathers-errors', () => {
done();
});
});

it('400', done => {
request({
url: 'http://localhost:5050/bad-request',
json: true
}, (error, res, body) => {
assert.equal(res.statusCode, 400);
assert.deepEqual(body, { name: 'BadRequest',
message: 'Invalid Password',
code: 400,
className: 'bad-request',
data: {
message: 'Invalid Password'
},
errors: [{
path: 'password',
value: null,
message: `'password' cannot be 'null'`
}]
});
done();
});
});
});
});
});

0 comments on commit b8d84c3

Please sign in to comment.