Last active
July 23, 2018 19:51
-
-
Save OKiMaureen/981d2d1332106361305ebf887bfcdc68 to your computer and use it in GitHub Desktop.
Fargo-Maureen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import app from 'somewhere that does not exist'; | |
describe('POST /api/articles', () => { | |
it('should not add article with an empty description field', ()=>{ | |
chai.request(app) | |
.post(/api/articles); | |
.set('token', dummyToken); | |
.send({ | |
title: 'Good Article', | |
body: 'Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque', | |
decription: '', | |
image: 'image link url' | |
}) | |
.end((err, res) => { | |
expect(res.status).to.equal(406); | |
expect(res.body.errors).to.be.an('object'); | |
expect(res.body.errors.body).to.be.an('array'); | |
expect(res.body.errors.body[0]).to.equal('description can\'t be empty'); | |
done(); | |
}) | |
}) | |
}) |
Nice attempt! You checked for empty description, I bet no user will be able to create an article without description with this test, that's fine, keep it up.
Good job with how you setup your test Maureen, Keep it up.
Good job! Your test cases are well laid out, but won't it be more preferable to return a status code of 400 Bad request
instead of a 406 Not Acceptable
?. In all, Nice work, keep it up.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice job Maureen! Keep up the good job and reflect for more egde cases.