Skip to content
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: requestAnimationFrame args #458

Merged
merged 5 commits into from Dec 15, 2022
Merged

fix: requestAnimationFrame args #458

merged 5 commits into from Dec 15, 2022

Conversation

CreativeTechGuy
Copy link
Contributor

Purpose (TL;DR)

Fix issue #454 by computing requestAnimationFrame args at the time when the callback is fired.

Copy link
Contributor

@fatso83 fatso83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, but lacking a test to verify its functionality

src/fake-timers-src.js Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Base: 95.52% // Head: 95.53% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (cf18928) compared to base (ad1d43c).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #458   +/-   ##
=======================================
  Coverage   95.52%   95.53%           
=======================================
  Files           2        2           
  Lines         648      649    +1     
=======================================
+ Hits          619      620    +1     
  Misses         29       29           
Flag Coverage Δ
unit 95.53% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/fake-timers-src.js 95.52% <100.00%> (+<0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@CreativeTechGuy
Copy link
Contributor Author

For the record, I am preserving the existing behavior which passes clock.now in the case where performance.now() isn't available. But that should probably be changed too since that doesn't match the browser's behavior. Should we break out the function that is used to implement performance.now() to be usable even when that method isn't mocked? That way requestAnimationFrame's args could be accurate in all cases?

@fatso83
Copy link
Contributor

fatso83 commented Dec 5, 2022

Should we break out the function that is used to implement performance.now() to be usable even when that method isn't mocked?

Yes, I think that makes perfect sense! Separate commit and separate test case :)

@CreativeTechGuy
Copy link
Contributor Author

You got it @fatso83! New commit and updated tests. Hope you like it 😃

Copy link
Contributor

@fatso83 fatso83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll await what you think about my comments. Otherwise great stuff ✌️

test/fake-timers-test.js Show resolved Hide resolved
src/fake-timers-src.js Outdated Show resolved Hide resolved
src/fake-timers-src.js Outdated Show resolved Hide resolved
@CreativeTechGuy
Copy link
Contributor Author

@fatso83 Let me know if the latest changes address all of your concerns. I think this is good to go!

@fatso83 fatso83 merged commit 8179e1a into sinonjs:main Dec 15, 2022
@CreativeTechGuy CreativeTechGuy deleted the request-animation-frame branch December 15, 2022 07:18
@SimenB
Copy link
Member

SimenB commented Dec 15, 2022

Lockfile was changed from v2 to v1, probably not on purpose 🙂

@CreativeTechGuy
Copy link
Contributor Author

CreativeTechGuy commented Dec 15, 2022

@SimenB Oh no! I'm not even sure how that could have accidentally happened. I would have understood if it upgraded to v3 somehow, but downgraded? No clue! I blame GitHub Codespaces' auto-setup haha.

How would you like me to fix it? I definitely didn't intend to change anything in that file, I'm so sorry it got committed.

@SimenB
Copy link
Member

SimenB commented Dec 15, 2022

I wouldn't worry about it, it doesn't really matter. Just a bit of extra diff 👍

@CreativeTechGuy
Copy link
Contributor Author

I tried to reproduce it with a fresh GitHub Codespace and instantly upon setup it converted it back to v2 so I have no clue what I did. I guess whoever does the next PR will likely (either intentionally or accidentally) upgrade it to v2 again! haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants