diff --git a/webapp/components/comments/CommentForm/CommentForm.test.js b/webapp/components/comments/CommentForm/CommentForm.test.js deleted file mode 100644 index 6453f689a..000000000 --- a/webapp/components/comments/CommentForm/CommentForm.test.js +++ /dev/null @@ -1,74 +0,0 @@ -import { config, mount, createLocalVue } from '@vue/test-utils' -import CommentForm from './index.vue' -import Vue from 'vue' -import Styleguide from '@human-connection/styleguide' - -const localVue = createLocalVue() - -localVue.use(Styleguide) - -config.stubs['no-ssr'] = '' - -describe('CommentForm.vue', () => { - let mocks - let wrapper - let form - let propsData - let submitBtn - let cancelBtn - - beforeEach(() => { - mocks = { - $t: jest.fn(), - $apollo: { - mutate: jest - .fn() - .mockRejectedValue({ message: 'Ouch!' }) - .mockResolvedValueOnce({ data: { CreateComment: { contentExcerpt: 'this is a comment' } } }) - }, - $toast: { - error: jest.fn(), - success: jest.fn() - }, - $root: { - $emit: jest.fn() - } - }, - propsData = { - post: { id: 1 } - } - }) - - describe('mount', () => { - const Wrapper = () => { - return mount(CommentForm, { mocks, localVue, propsData }) - } - - beforeEach(() => { - wrapper = Wrapper() - }) - - it('calls the apollo mutation when form is submitted', () => { - wrapper.vm.updateEditorContent('ok') - form = wrapper.find('form') - form.trigger('submit') - expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1) - }) - - it("calls clear method when the cancel button is clicked", () => { - const spy = jest.spyOn(wrapper.vm, 'clear') - wrapper.vm.updateEditorContent('ok') - cancelBtn = wrapper.find('.cancelBtn') - cancelBtn.trigger('click') - expect(spy).toHaveBeenCalledTimes(1) - }) - - it('shows a success toaster if the mutation resolves', () => { - wrapper.vm.updateEditorContent('ok') - form = wrapper.find('form') - form.trigger('submit') - expect(mocks.$root.$emit).toHaveBeenCalledTimes(1) - expect(mocks.$toast.success).toHaveBeenCalledTimes(1) - }) - }) -}) \ No newline at end of file diff --git a/webapp/components/comments/CommentForm/index.vue b/webapp/components/comments/CommentForm/index.vue index 4377e2e2c..585b97dba 100644 --- a/webapp/components/comments/CommentForm/index.vue +++ b/webapp/components/comments/CommentForm/index.vue @@ -20,8 +20,8 @@ {{ $t('actions.cancel') }} @@ -92,7 +92,6 @@ export default { } }) .then(res => { - // console.log(this.$toast.success.mockResolvedValue()) this.$root.$emit('addComment', res.data.CreateComment) this.$refs.editor.clear() this.$toast.success(this.$t('post.comment.submitted'))