Skip to content

Instantly share code, notes, and snippets.

@klevamane
Last active July 24, 2018 14:53
Show Gist options
  • Save klevamane/c39b3d7ee0179d551a9edbf78256c9c1 to your computer and use it in GitHub Desktop.
Save klevamane/c39b3d7ee0179d551a9edbf78256c9c1 to your computer and use it in GitHub Desktop.
Test case to delete an article
import app from 'location/of/app'
// Assume npm packages has been installed
import chaiHttp from 'chai-http';
import chai from 'chai';
import app from '../app';
const { expect } = chai;
let adminAuthToken = res.body.someToken;
chai.use(chaiHttp);
describe('Delete an Article', () => {
const slug = 'a-slog-that-exist-in-the-database';
it('should delete an article', (done) => {
chai.request(app)
.delete(`/api/articles/${slug)`)
.set('Authorization', `Bearer ${adminAuthToken}`)
.end((err, res ) => {
expect(res).to.have.status(200);
expect(res.body.message).to.equal('The Article has been deleted');
})
});
});
@OKiMaureen
Copy link

Good job on your TDD, great initiative on thinking about the possible scenarios.

@ascii-dev
Copy link

Great job. I like the fact that your test not only checks for the right HTTP status code but also checks for the message passed.

@Lumexralph
Copy link

Nice job on testing for when an article is deleted. Keep it up and reflect on more edge cases.

@veeqtor
Copy link

veeqtor commented Jul 23, 2018

Excellent piece!, very well laid out. Nice work.

@Oloyedesinmiloluwa
Copy link

Great Job! You handled the test case well, keep it up

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