Skip to content

Instantly share code, notes, and snippets.

@OKiMaureen
Last active July 23, 2018 19:51
Show Gist options
  • Save OKiMaureen/981d2d1332106361305ebf887bfcdc68 to your computer and use it in GitHub Desktop.
Save OKiMaureen/981d2d1332106361305ebf887bfcdc68 to your computer and use it in GitHub Desktop.
Fargo-Maureen
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();
})
})
})
@Oloyedesinmiloluwa
Copy link

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.

@anneKay
Copy link

anneKay commented Jul 23, 2018

Good job with how you setup your test Maureen, Keep it up.

@veeqtor
Copy link

veeqtor commented Jul 23, 2018

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