Skip to content

Instantly share code, notes, and snippets.

@rajasekarm
Created December 21, 2018 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajasekarm/32890e605b7a32cdec36c8c370d0dd2a to your computer and use it in GitHub Desktop.
Save rajasekarm/32890e605b7a32cdec36c8c370d0dd2a to your computer and use it in GitHub Desktop.
describe('routes : topics', () => {
beforeEach((done) => {
this.topic;
sequelize.sync({force: true}).then((res) => {
Topic.create({
title: 'JS Frameworks',
description: 'There is a lot of them'
})
.then((topic) => {
this.topic = topic;
done();
})
.catch((err) => {
console.log(err);
done();
});
});
});
describe('POST /topics/:id/destroy', () => {
it('should delete the topics with associated ID', (done) => {
Topic.all()
.then((topics) => {
const topicCountBeforeDelete = topics.length;
expect(topicCountBeforeDelete).toBe(1);
request.post(`${base}${this.topic.id}/destroy`, (err, res, body) => {
Topic.all()
.then((topics) => {
console.log(topicCountBeforeDelete, topics.length);
expect(err).toBeNull();
expect(topics.length).toBe(topicCountBeforeDelete - 1);
done();
})
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment