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

[jest] Fix missing mock for StatusBarManager #11198

Closed
wants to merge 1 commit into from

Conversation

mlanter
Copy link
Contributor

@mlanter mlanter commented Nov 29, 2016

Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger.

More info:
In one of my files I have:

export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0);

When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20)

TypeError: Cannot read property 'HEIGHT' of undefined      
  at Object.<anonymous> (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823)
  at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24)

Test plan (required)
Verify that with this change tests that use StatusBar pass.

Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger. 

More info:
In one of my files I have:
```
export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0);
```
When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20)

```
TypeError: Cannot read property 'HEIGHT' of undefined      
  at Object.<anonymous> (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823)
  at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24)
```

**Test plan (required)**
Verify that with this change tests that use StatusBar pass.
@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @cpojer to be a potential reviewer.

@mlanter
Copy link
Contributor Author

mlanter commented Nov 29, 2016

@cpojer Fix for StatusBar from jestjs/jest#1840. Thanks for your help!

@facebook-github-bot
Copy link
Contributor

@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@cpojer
Copy link
Contributor

cpojer commented Nov 29, 2016

:)

@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 Nov 29, 2016
cooperka added a commit to cooperka/react-native that referenced this pull request Nov 29, 2016
facebook-github-bot pushed a commit that referenced this pull request Nov 29, 2016
Summary:
**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.

```jsx
import React, { Component } from 'react';
import { AppState } from 'react-native';

class TestComponent extends Component {
  componentDidMount() {
    AppState.addEventListener('change', this.stateChangeListener);
  }
}
```
Closes #11199

Differential Revision: D4246668

Pulled By: cpojer

fbshipit-source-id: e3a73a98963a0e152a70aba78ef3461b86da0f6c
robclouth pushed a commit to robclouth/react-native that referenced this pull request Dec 7, 2016
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
robclouth pushed a commit to robclouth/react-native that referenced this pull request Dec 7, 2016
Summary:
Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger.

**More info:**
In one of my files I have:
```
export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0);
```
When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20)

```
TypeError: Cannot read property 'HEIGHT' of undefined
  at Object.<anonymous> (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823)
  at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24)
```

**Test plan (required)**
Verify that with this change tests that use StatusBar pass.
Closes facebook#11198

Differential Revision: D4246367

Pulled By: cpojer

fbshipit-source-id: ee9406d2566688d235a11cab8f24b0583698e93a
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
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
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
Summary:
Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger.

**More info:**
In one of my files I have:
```
export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0);
```
When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20)

```
TypeError: Cannot read property 'HEIGHT' of undefined
  at Object.<anonymous> (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823)
  at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24)
```

**Test plan (required)**
Verify that with this change tests that use StatusBar pass.
Closes facebook#11198

Differential Revision: D4246367

Pulled By: cpojer

fbshipit-source-id: ee9406d2566688d235a11cab8f24b0583698e93a
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants