Created
December 21, 2018 02:43
-
-
Save rajasekarm/32890e605b7a32cdec36c8c370d0dd2a to your computer and use it in GitHub Desktop.
Revisions
-
rajasekarm created this gist
Dec 21, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ 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(); }) }); }); }); }); });