vue-debounce icon indicating copy to clipboard operation
vue-debounce copied to clipboard

Put some information for testing inside vue utils

Open Natega opened this issue 3 years ago • 2 comments

Can you add some information on how to test a component with debounce directive. Thx

Natega avatar Jul 02 '21 13:07 Natega

Sorry, I've been swamped with work things to really look into this, so I'm still researching the best approach.

dhershman1 avatar Jul 23 '21 15:07 dhershman1

@Natega FYI I just ended up building a mocked directive :

export const vueDebounceMockDirective = {
  created(el: any, binding: { value: (...args: any[]) => void }) {
    const debouncedFn = binding.value;

    el.addEventListener('input', (event: any) => {
      debouncedFn(event.target.value);
    });
  }
};

And I use it in my test like this :

// MountingOptions
options = {
  global: {
    // ...
    directives: {
      debounce: vueDebounceMockDirective
     }
 },

It works well using vue-test-utils setValue.

Good luck everyone ! And thank you @dhershman1 for the great lib !

renaud-dev avatar Apr 11 '23 16:04 renaud-dev