-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix debounce function bug when immediate is true #243
base: master
Are you sure you want to change the base?
Conversation
When immediate is true, the debounced func will never called.
Thanks. Could you add a test for that? |
OK, I've added it. |
Thank you so much! |
|
||
setTimeout(() => { | ||
if (callCount === 2 && intervalCount === 3) done(); | ||
else done(`callCount = ${callCount}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is assertion? Honestly i don't understand this test, you should stub () => callCount++
and check how many calls debounce called this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's my first test unit, but I think it does work. It's true I didn't write any "assert" keyword to do the assertion, but I did use "done" which I think did the job well. Although, stub may be a good way to finish the job but I think stub is not available in mochaJs or assert module. It's not wise to import extra modules when the job can be done easily, at least for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ODudek Any updates?
Looks like this can be closed due to the merge of #362 |
5559a1c
to
bd9b25e
Compare
Is there a reason this is still open? See #362. |
When immediate is true, the debounced func will never called.