From 745a326fbe74678c49af6997c60a27c89d7099bb Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 27 May 2019 19:16:27 -0300 Subject: [PATCH] Test refetching a Post with its comments --- .../comments/CommentList/CommentList.spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/webapp/components/comments/CommentList/CommentList.spec.js b/webapp/components/comments/CommentList/CommentList.spec.js index 55a75fbb2..9bfa13ea5 100644 --- a/webapp/components/comments/CommentList/CommentList.spec.js +++ b/webapp/components/comments/CommentList/CommentList.spec.js @@ -33,6 +33,13 @@ describe('CommentList.vue', () => { }) mocks = { $t: jest.fn(), + $apollo: { + queries: { + Post: { + refetch: jest.fn(), + }, + }, + }, } data = () => { return { @@ -63,5 +70,10 @@ describe('CommentList.vue', () => { it('displays comments when there are comments to display', () => { expect(wrapper.find('div#comments').text()).toEqual('this is a comment') }) + + it("refetches a post's comments from the backend", () => { + wrapper.vm.refetchPostComments() + expect(mocks.$apollo.queries.Post.refetch).toHaveBeenCalledTimes(1) + }) }) })