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

test(AnimatedMock): make mocks .start callback async + implemented on all animations #31992

Conversation

Michael-M-Judd
Copy link

@Michael-M-Judd Michael-M-Judd commented Aug 9, 2021

Summary

When mocked Animated using the AnimatedMock, I noticed a few things that were off with the mocks that weren't happening with real code:

  1. The mocks call the callback from .start() synchronously. I've changed this to make it async so that it's more like the real Animated behaviour
  2. The mocks for .parallel, .decay, .stagger, .sequence, and .loop all used the emptyAnimation object which doesn't implement the .start(cb) callback like timing/spring do.

This should also fix #25615

Changelog

[General] [Fixed] - AnimatedMock .parallel, .stagger, .sequence, .loop now correctly call the callback passed to .start
[General] [Fixed] - All AnimatedMock .start callback methods are now called async instead of synchronously to better simulate the production environment

Test Plan

  • Added new tests to assert that they work as expected
  • Also ran these changes against our own codebase and fixed a few issues 🎉

@facebook-github-bot
Copy link
Contributor

Hi @Michael-M-Judd!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 9, 2021
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 91cac20

@analysis-bot
Copy link

analysis-bot commented Aug 9, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 9,190,278 +22
android hermes armeabi-v7a 8,715,903 +13
android hermes x86 9,632,310 +19
android hermes x86_64 9,599,899 +13
android jsc arm64-v8a 10,826,329 +10
android jsc armeabi-v7a 9,743,236 +16
android jsc x86 10,863,757 +12
android jsc x86_64 11,472,862 +13

Base commit: 91cac20

it('calls the start callback', () => {
AnimatedMock.parallel([]).start(mockStartCallback);

jest.runAllTimers();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we call runAllTimers twice? Do we need to call it in the test if its part of itCallsStartCallback?

@lunaleaps lunaleaps self-assigned this Sep 8, 2021
@yungsters yungsters added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 10, 2021
@github-actions
Copy link

github-actions bot commented Apr 4, 2022

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 4, 2022
@github-actions
Copy link

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Needs: Author Feedback Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New AnimatedMock don't call animation end callback
6 participants