Merge pull request #690 from Human-Connection/582-edit-field-bug-comment-form

Fix edit field render bug(CommentForm)
This commit is contained in:
Robert Schäfer 2019-05-28 00:46:05 +02:00 committed by GitHub
commit 27b8848892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 15 deletions

View File

@ -5,14 +5,12 @@
> >
<template slot-scope="{ errors }"> <template slot-scope="{ errors }">
<ds-card> <ds-card>
<no-ssr> <hc-editor
<hc-editor ref="editor"
ref="editor" :users="users"
:users="users" :value="form.content"
:value="form.content" @input="updateEditorContent"
@input="updateEditorContent" />
/>
</no-ssr>
<ds-space /> <ds-space />
<ds-flex :gutter="{ base: 'small', md: 'small', sm: 'x-large', xs: 'x-large' }"> <ds-flex :gutter="{ base: 'small', md: 'small', sm: 'x-large', xs: 'x-large' }">
<ds-flex-item :width="{ base: '0%', md: '50%', sm: '0%', xs: '0%' }" /> <ds-flex-item :width="{ base: '0%', md: '50%', sm: '0%', xs: '0%' }" />

View File

@ -1,4 +1,4 @@
import { config, mount, createLocalVue, createWrapper } from '@vue/test-utils' import { mount, createLocalVue, createWrapper } from '@vue/test-utils'
import CommentForm from './index.vue' import CommentForm from './index.vue'
import Styleguide from '@human-connection/styleguide' import Styleguide from '@human-connection/styleguide'
@ -6,8 +6,6 @@ const localVue = createLocalVue()
localVue.use(Styleguide) localVue.use(Styleguide)
config.stubs['no-ssr'] = '<span><slot /></span>'
describe('CommentForm.vue', () => { describe('CommentForm.vue', () => {
let mocks let mocks
let wrapper let wrapper

View File

@ -33,6 +33,13 @@ describe('CommentList.vue', () => {
}) })
mocks = { mocks = {
$t: jest.fn(), $t: jest.fn(),
$apollo: {
queries: {
Post: {
refetch: jest.fn(),
},
},
},
} }
data = () => { data = () => {
return { return {
@ -63,5 +70,10 @@ describe('CommentList.vue', () => {
it('displays comments when there are comments to display', () => { it('displays comments when there are comments to display', () => {
expect(wrapper.find('div#comments').text()).toEqual('this is a comment') 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)
})
}) })
}) })

View File

@ -54,13 +54,15 @@ export default {
}, },
}, },
mounted() { mounted() {
this.$root.$on('refetchPostComments', comment => { this.$root.$on('refetchPostComments', () => {
this.refetchPostComments(comment) this.refetchPostComments()
}) })
}, },
methods: { methods: {
refetchPostComments(comment) { refetchPostComments() {
this.$apollo.queries.Post.refetch() if (this.$apollo.queries.Post) {
this.$apollo.queries.Post.refetch()
}
}, },
}, },
apollo: { apollo: {