-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Review _.throttle, _.debounce tests for time tampering #2883
Comments
Hey @jgonggrijp 👋 Giving a glimpse to the implementation of I would be willing to submit PR, but would perhaps need a little guidance on it. Cheers! |
Hey @ognjenjevremovic 👋 Thanks for taking a peek at this, and for adding the links. I guess I should have done that immediately.
Well, that's basically the core question of this issue. You can't influence If you're able to do this, then the tests in question should be updated to override
Yes, this is only about the tests.
I haven't investigated in detail, but please feel free to search for such tests. Cheers! |
Thanks for getting back to me. I'll do some research regarding the I'll post some updates when I have some 🙂 . |
Monkey patch `Date.prototype` getTime and valueOf methods and `Date.now` method in _.debounce and _.throttle test cases. Provide additional test case asserting the outputs before and after monkey patching. Remove the reference to _.now method in test cases as the underlying implementation of library methods don't reference the methods from the `_` object but rather call dependent methods directly. ✅ Closes: jashkenas#2883
_.throttle
and_.debounce
both have a test to confirm that the limiting time interval continues unaltered when_.now
is overridden. These tests can be found by searching thetest/
directory for the phraseafter system time is set backwards
.Since the modularization, these tests don't meet the intended purpose anymore; most Underscore functions now use direct references to other Underscore functions instead of indirect references through the
_
object. In a way, this has made them more tamper-proof. This also applies to the use of_.now
in_.throttle
and_.debounce
.How to resolve this issue depends on whether there is any other way to tamper with the time as it is reported by
_.now
. If there is such a way, then the tests in question should be updated to use it. Otherwise, the tests can be removed.The text was updated successfully, but these errors were encountered: