Clear input after submit
This commit is contained in:
parent
f7ecb82cda
commit
c04f1a3f3f
|
|
@ -12,7 +12,7 @@
|
||||||
<a
|
<a
|
||||||
data-cy="submit-comment"
|
data-cy="submit-comment"
|
||||||
class="button button--primary"
|
class="button button--primary"
|
||||||
@click="$emit('submit', text)">Kommentar teilen</a>
|
@click="submit()">Kommentar teilen</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -40,6 +40,10 @@
|
||||||
},
|
},
|
||||||
addEmoji(emoji) {
|
addEmoji(emoji) {
|
||||||
this.text = this.text + emoji;
|
this.text = this.text + emoji;
|
||||||
|
},
|
||||||
|
submit() {
|
||||||
|
this.$emit('submit', this.text);
|
||||||
|
this.text = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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]);
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue