Skip to content

Commit

Permalink
add delete deep checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ezy committed Jul 24, 2018
1 parent 5f827c4 commit de9696a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/post/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,29 @@ describe('[POST] /api/posts Testing', () => {
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
postSlug = res.body.post.postSlug;
expect(res.body.post).to.be.an('object');
expect(res.body.post).to.have.all.keys(postKeys);
expect(res.body.post.postSlug).to.include(changeCase.paramCase(newTitle));
done();
});
});

it('update should error with wrong post slug', (done) => {
request(app)
.patch('/api/posts/no-post-here')
.send(postRequest)
.set('Authorization', `Bearer ${token}`)
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(400)
.end((err, res) => {
expect(res.body).to.have.property('error');
expect(res.body).to.have.deep.property('error', 'No post found');
done();
});
});

it('should be able to delete a post if logged in', (done) => {
request(app)
.delete(`/api/posts/${postSlug}`)
Expand All @@ -144,6 +160,8 @@ describe('[POST] /api/posts Testing', () => {
.expect(202)
.end((err, res) => {
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('success');
expect(res.body).to.have.deep.property('success', 'Post successfully deleted.');
done();
});
});
Expand Down

0 comments on commit de9696a

Please sign in to comment.