Commit Graph

9 Commits

Author SHA1 Message Date
Nelen 2190221c44 Added mocked functions to StatusBarManager
Summary:
**Description:**
Jest tests that use that StatusBar failing because the status bar functions aren't mocked.
Errors I ran into:
`TypeError: StatusBarManager. setNetworkActivityIndicatorVisible is not a function`
`TypeError: StatusBarManager. setHidden is not a function`
`TypeError: StatusBarManager. setStyle is not a function`

**Fix:**
Added mocks for all the functions that the StatusBar offers according to the docs: https://facebook.github.io/react-native/docs/statusbar.html

**Test plan (required)**
Verify that the tests using StatusBar and its functions succeed.
Closes https://github.com/facebook/react-native/pull/11322

Differential Revision: D4284536

Pulled By: cpojer

fbshipit-source-id: b67be8c0595d91ee9aca4784f457c0959d7e45d5
2016-12-06 05:58:32 -08:00
mlanter 39554ab32c Fix missing mock for StatusBarManager
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 https://github.com/facebook/react-native/pull/11198

Differential Revision: D4246367

Pulled By: cpojer

fbshipit-source-id: ee9406d2566688d235a11cab8f24b0583698e93a
2016-11-29 22:13:44 -08:00
Kevin Cooper 00f888a318 Add missing mock for AppState
Summary:
**Description**

In the same vein as https://github.com/facebook/react-native/pull/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 https://github.com/facebook/react-native/pull/11199

Differential Revision: D4246668

Pulled By: cpojer

fbshipit-source-id: e3a73a98963a0e152a70aba78ef3461b86da0f6c
2016-11-29 14:43:38 -08:00
Tim Yung 23331df5a4 RN: Cleanup OSS JS & Flow Declarations
Reviewed By: vjeux

Differential Revision: D4210763

fbshipit-source-id: 5abaa547100b8badd13bcf311ceffc5b4098d252
2016-11-20 17:58:29 -08:00
Cristian Carlesso 6d3e074dd4 Adding Jest preset so that people can configure Jest using react-native as preset
Reviewed By: cpojer

Differential Revision: D4081817

fbshipit-source-id: 43cf2ec467ea69651705162b6a58e0b3f1ad1dbf
2016-10-31 12:58:35 -07:00
Cristian Carlesso 9833e1bd34 Fixes typo
Reviewed By: bestander

Differential Revision: D4103918

fbshipit-source-id: 1176f97cf489180490e497be7deca331ed26e730
2016-10-31 09:28:36 -07:00
Cristian Carlesso 45275e30b9 Fixes Components with prefixes in mock
Reviewed By: bestander

Differential Revision: D4096027

fbshipit-source-id: 342677a27c6d03dc7d2d6eb53970a504fb62d63b
2016-10-28 10:58:39 -07:00
Christoph Pojer 487171fd89 Mock requireNativeComponent so manual mocking of UIManager properties isn't needed
Summary:
Fixes warnings such as `Warning: Native component for "RCTView" does not exist` when you don't mock the native view class on `UIManager`.

**Test plan (required)**

Run `npm test` with it and without it, notice that warnings are gone and results are the same.

cc cpojer
Closes https://github.com/facebook/react-native/pull/10486

Differential Revision: D4063500

Pulled By: cpojer

fbshipit-source-id: f6bdda1fdd1ad87958f435071d353684cb812af4
2016-10-22 20:28:42 -07:00
Cristian Carlesso 6a462fb085 Moving the jest configuration from jest-react-native to react native.
Reviewed By: cpojer

Differential Revision: D3923609

fbshipit-source-id: 62804df81b064871b499ae8c091e13dd1e0f229b
2016-10-17 08:44:05 -07:00