Skip to content

Instantly share code, notes, and snippets.

@ascii-dev
Last active July 23, 2018 19:36
Show Gist options
  • Save ascii-dev/d8da20e4e22a4e2ac69709bc8b26d946 to your computer and use it in GitHub Desktop.
Save ascii-dev/d8da20e4e22a4e2ac69709bc8b26d946 to your computer and use it in GitHub Desktop.
describe('/POST /api/articles', () => {
const data = {
title: "How to train your dragon",
description: "Ever wonder how?",
body: "You have to believe",
tagList: ["reactjs", "angularjs", "dragons"]
};
it('should create a new article if required fields are entered', (done) => {
chai.request(app)
.get('/api/articles/')
.set('Authorization', 'Bearer theusersjwtoken')
.send(data)
.end((err, res) => {
res.should.have.status(201);
res.body.should.be.a('object');
res.body.should.have.property('message').to.equals('Your request has been created successfully');
done();
});
});
});
@Lumexralph
Copy link

Nice one! You did a good coverage on the test case.

@Oloyedesinmiloluwa
Copy link

Good approach! You checked if the response object contains a success message, that's good practice keep it up

@veeqtor
Copy link

veeqtor commented Jul 23, 2018

Great Job!, You covered all test cases for the POST request, Keep it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment