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

Add missing mock for AppState (removeEventListener) #17908

Closed
wants to merge 1 commit into from
Closed

Add missing mock for AppState (removeEventListener) #17908

wants to merge 1 commit into from

Conversation

MoOx
Copy link
Contributor

@MoOx MoOx commented Feb 8, 2018

Motivation

I am testing with Jest a component that use AppState.removeEventListener and I am currently facing a fatal error saying that AppState.removeEventListener is undefined.

Test Plan

Create a component that uses AppState, e.g.

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)

Related PRs

It's the continuation of #11199. This PR finish the mock for the native module AppState.

Release Notes

[ GENERAL ] [ BUGFIX ] [AppState] Add missing mock for Jest for removeEventListener method.

**Description**

In the same vein as #11199, this finish the 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);
  }
  componentWillUnmount() {
    AppState.removeEventListener('change', this.stateChangeListener);
  }
}
```

Reference: https://facebook.github.io/react-native/docs/appstate.html#removeeventlistener
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. cla signed labels Feb 8, 2018
@pull-bot
Copy link

pull-bot commented Feb 8, 2018

Warnings
⚠️

📋 Release Notes - This PR may have incorrectly formatted Release Notes.

@facebook-github-bot label Needs more information

Generated by 🚫 dangerJS

@facebook-github-bot
Copy link
Contributor

Something went wrong executing that command, @mkonicek could you take a look?

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Feb 26, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants