I have an input text field, where when a user types, I am setting a state and passing the setter as onChange function, something like this-
const [searchText, setSearchText] = React.useState('');
// Invoke input component
<input type='input' onChange={setSearchText} />
// When input changes, debounce it and call another function
useDebounceFunction();
I want to write tests for this chunk of code- I have written when input changes, then the setter should be invoked and that's working fine, but how can I write a test in jest for debounce function? When my input text is changing, then after 1 sec, I am invoking a function inside debounce handler.
Aucun commentaire:
Enregistrer un commentaire