diff --git a/webapp/components/CommentList/CommentList.spec.js b/webapp/components/CommentList/CommentList.spec.js index d0d54aa68..39f76ff12 100644 --- a/webapp/components/CommentList/CommentList.spec.js +++ b/webapp/components/CommentList/CommentList.spec.js @@ -1,6 +1,5 @@ import { config, mount } from '@vue/test-utils' import CommentList from './CommentList' -import CommentCard from '~/components/CommentCard/CommentCard' import Vuex from 'vuex' import Vue from 'vue' @@ -26,7 +25,10 @@ describe('CommentList.vue', () => { id: 'comment134', contentExcerpt: 'this is a comment', content: 'this is a comment', - author: { id: 'some-user' }, + author: { + id: 'some-user', + slug: 'some-slug', + }, }, { id: 'comment135', @@ -49,7 +51,7 @@ describe('CommentList.vue', () => { getters: { 'auth/isModerator': () => false, 'auth/user': () => { - return {} + return { id: 'some-user' } }, }, }) @@ -115,26 +117,63 @@ describe('CommentList.vue', () => { }) }) - describe('Comment', () => { + describe('Respond to Comment', () => { beforeEach(() => { wrapper = Wrapper() }) - it('Comment emitted reply()', () => { - wrapper.find(CommentCard).vm.$emit('reply', { - id: 'commentAuthorId', - slug: 'ogerly', - }) - Vue.nextTick() + it('emits reply to comment', () => { + wrapper.find('.reply-button').trigger('click') expect(wrapper.emitted('reply')).toEqual([ [ { - id: 'commentAuthorId', - slug: 'ogerly', + id: 'some-user', + slug: 'some-slug', }, ], ]) }) }) + + describe('edit Comment', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('updates comment after edit', () => { + wrapper.vm.updateCommentList({ + id: 'comment134', + contentExcerpt: 'this is an edited comment', + content: 'this is an edited comment', + author: { + id: 'some-user', + slug: 'some-slug', + }, + }) + expect(wrapper.props('post').comments[0].content).toEqual('this is an edited comment') + }) + }) + + describe('delete Comment', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + // TODO: Test does not find .count = 0 but 1. Can't understand why... + it.skip('sets counter to 0', async () => { + wrapper.vm.updateCommentList({ + id: 'comment134', + contentExcerpt: 'this is another deleted comment', + content: 'this is an another deleted comment', + deleted: true, + author: { + id: 'some-user', + slug: 'some-slug', + }, + }) + await Vue.nextTick() + await expect(wrapper.find('.count').text()).toEqual('0') + }) + }) }) })