diff --git a/client/src/components/rooms/CommentInput.vue b/client/src/components/rooms/CommentInput.vue index 36eed06a..ad2fe375 100644 --- a/client/src/components/rooms/CommentInput.vue +++ b/client/src/components/rooms/CommentInput.vue @@ -12,7 +12,7 @@ Kommentar teilen + @click="submit()">Kommentar teilen @@ -40,6 +40,10 @@ }, addEmoji(emoji) { this.text = this.text + emoji; + }, + submit() { + this.$emit('submit', this.text); + this.text = ''; } }, }; diff --git a/client/tests/unit/comment-input.spec.js b/client/tests/unit/comment-input.spec.js new file mode 100644 index 00000000..745e44d9 --- /dev/null +++ b/client/tests/unit/comment-input.spec.js @@ -0,0 +1,23 @@ +import {createLocalVue, shallowMount} from '@vue/test-utils' +import CommentInput from '@/components/rooms/CommentInput'; + +const localVue = createLocalVue() + +describe('CommentInput.vue', () => { + + it('should clear input after submit', async () => { + const inputText = 'some value'; + + const wrapper = shallowMount(CommentInput, { + localVue + }); + + const textInput = wrapper.find('[data-cy="comment-textarea"]'); + await textInput.setValue(inputText); + + wrapper.vm.submit(); + + expect(wrapper.emitted()['submit'][0]).toEqual([inputText]); + }); + +})