-
Notifications
You must be signed in to change notification settings - Fork 24.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
[jest] Add missing mock for AppState #11199
Conversation
In the same vein as facebook#11198
By analyzing the blame information on this pull request, we identified @cpojer to be a potential reviewer. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact [email protected] if you have any questions. |
@cpojer Yet another fix related to the issue brought up in jestjs/jest#1840. Thanks for the suggestion :) |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
nice! |
Summary: **Description** In the same vein as facebook#11198, this adds a mock for the native module `AppState`. **Test plan** Create a component that uses `AppState`, e.g. ```jsx import React, { Component } from 'react'; import { AppState } from 'react-native'; class TestComponent extends Component { componentDidMount() { AppState.addEventListener('change', this.stateChangeListener); } } ``` Closes facebook#11199 Differential Revision: D4246668 Pulled By: cpojer fbshipit-source-id: e3a73a98963a0e152a70aba78ef3461b86da0f6c
Summary: **Description** In the same vein as facebook#11198, this adds a mock for the native module `AppState`. **Test plan** Create a component that uses `AppState`, e.g. ```jsx import React, { Component } from 'react'; import { AppState } from 'react-native'; class TestComponent extends Component { componentDidMount() { AppState.addEventListener('change', this.stateChangeListener); } } ``` Closes facebook#11199 Differential Revision: D4246668 Pulled By: cpojer fbshipit-source-id: e3a73a98963a0e152a70aba78ef3461b86da0f6c
Summary: I am testing with Jest a component that use [AppState.removeEventListener](https://facebook.github.io/react-native/docs/appstate.html#removeeventlistener) and I am currently facing a fatal error saying that `AppState.removeEventListener` is `undefined`. Create a component that uses `AppState`, e.g. ```jsx import React, { Component } from 'react'; import { AppState } from 'react-native'; class TestComponent extends Component { componentDidMount() { AppState.addEventListener('change', this.stateChangeListener); } componentWillUnmount() { AppState.removeEventListener('change', this.stateChangeListener); } } ``` It should pass test using Jest (snapshots) It's the continuation of #11199. This PR finish the mock for the native module `AppState`. [ GENERAL ] [ BUGFIX ] [AppState] Add missing mock for Jest for `removeEventListener` method. Closes #17908 Differential Revision: D7083144 Pulled By: shergin fbshipit-source-id: eafa07f064f971c3d657f2ffc9c00766c0925bac
Description
In the same vein as #11198, this adds a mock for the native module
AppState
.Test plan
Create a component that uses
AppState
, e.g.