Skip to content

Commit

Permalink
bg(fix): update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mchardex committed Apr 4, 2019
1 parent 5031545 commit 1e2fd8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions server/helpers/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const validations = {
},
validateInput: (err, res, next) => {
if (err) {
res.status(422).json({
status: 422,
res.status(400).json({
status: 400,
errors: {
body: [err.details[0].message.split('"').join('')],
},
Expand Down
16 changes: 8 additions & 8 deletions tests/rating.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const rating = {
};

describe('POST RATING', () => {
it('should return 422 with invalid or empty payload(user_id)', done => {
it('should return 400 with invalid or empty payload(user_id)', done => {
chai
.request(app)
.post('/api/v1/rating')
Expand All @@ -21,14 +21,14 @@ describe('POST RATING', () => {
})
.end((req, res) => {
const { status, errors } = res.body;
expect(status).to.be.equal(422);
expect(status).to.be.equal(400);
expect(res).to.be.an('object');
expect(errors.body[0]).to.equal('user_id is required');
done();
});
});

it('should return 422 with invalid or empty payload(article_id)', done => {
it('should return 400 with invalid or empty payload(article_id)', done => {
chai
.request(app)
.post('/api/v1/rating')
Expand All @@ -38,13 +38,13 @@ describe('POST RATING', () => {
})
.end((req, res) => {
const { status, errors } = res.body;
expect(status).to.be.equal(422);
expect(status).to.be.equal(400);
expect(errors.body[0]).to.equal('article_id is required');
done();
});
});

it('should return 422 with invalid or empty payload(rating_value)', done => {
it('should return 400 with invalid or empty payload(rating_value)', done => {
chai
.request(app)
.post('/api/v1/rating')
Expand All @@ -54,7 +54,7 @@ describe('POST RATING', () => {
})
.end((req, res) => {
const { status, errors } = res.body;
expect(status).to.be.equal(422);
expect(status).to.be.equal(400);
expect(errors.body[0]).to.equal('rating_value is required');
done();
});
Expand All @@ -77,7 +77,7 @@ describe('POST RATING', () => {
});
});

it('should return 422 error if rating value is not between 0 and 5', done => {
it('should return 400 error if rating value is not between 0 and 5', done => {
chai
.request(app)
.post('/api/v1/rating')
Expand All @@ -88,7 +88,7 @@ describe('POST RATING', () => {
})
.end((req, res) => {
const { status, errors } = res.body;
expect(status).to.be.equal(422);
expect(status).to.be.equal(400);
expect(errors.body[0]).to.equal(
'rating_value must be less than or equal to 5'
);
Expand Down

0 comments on commit 1e2fd8a

Please sign in to comment.