how to trigger Blur event Jest

Viewed 2214

i got an input field with an @blur="function" prop. So i wanted to test whether the function gets called. I tried following code but It doesnt work. I've tested the function manuelly and the function gets called. I just cant test it with jest

Test:

    expect(wrapper.vm.searchString).toBe('');

    const textFieldElement = wrapper.find('.v-text-field');
    const input = wrapper.find('input');

    textFieldElement.vm.$emit('input', 'filter value');
    input.trigger("blur");

    expect(methods.funcion).toBeCalledTimes(1)
    expect(wrapper.vm.searchString).toBe('filter value');

Anyone any idea what could be wrong

0 Answers
Related