Skip to content

Instantly share code, notes, and snippets.

@rajasekarm
Created December 21, 2018 02:43
Show Gist options
  • Select an option

  • Save rajasekarm/32890e605b7a32cdec36c8c370d0dd2a to your computer and use it in GitHub Desktop.

Select an option

Save rajasekarm/32890e605b7a32cdec36c8c370d0dd2a to your computer and use it in GitHub Desktop.

Revisions

  1. rajasekarm created this gist Dec 21, 2018.
    41 changes: 41 additions & 0 deletions delete-post
    Original 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();
    })
    });
    });
    });
    });

    });