From 5f827c4c263b8c92c9b84336bd6622100919d9c5 Mon Sep 17 00:00:00 2001 From: Ezra Keddell Date: Wed, 25 Jul 2018 09:29:26 +1200 Subject: [PATCH] get update test working for post --- test/post/post.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/post/post.test.js b/test/post/post.test.js index e8bdedb..326a700 100644 --- a/test/post/post.test.js +++ b/test/post/post.test.js @@ -116,6 +116,25 @@ describe('[POST] /api/posts Testing', () => { }); }); + it('should be able to update a post if logged in', (done) => { + let updatedPost = postRequest, + newTitle = faker.lorem.sentence(1); + updatedPost.postTitle = newTitle; + request(app) + .patch(`/api/posts/${postSlug}`) + .send(updatedPost) + .set('Authorization', `Bearer ${token}`) + .set('Accept', 'application/json') + .expect('Content-Type', /json/) + .expect(200) + .end((err, res) => { + 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('should be able to delete a post if logged in', (done) => { request(app) .delete(`/api/posts/${postSlug}`)