When writing unit tests with ava
and vuejs
how can I trigger the Enter
keyup event?
For example, with the following component how can I test that someFunction
has been called?
<input
@keyup.enter="someFunction"
/>
I've found on vue-test-utils docs. I need to call input.trigger('keyup.enter');
Here is a full example:
test('it should call add mutation', t => {
const wrapper = mount(Todo, { localVue, store: createStore() });
const input = wrapper.find('.todo-value');
input.setValue('New todo item');
input.trigger('keyup.enter');
t.true(mutations.add.called);
});