Fix Jest mocks for NetInfo module.

Summary:
Jest mock for `NetInfo.getConnectionInfo()` is missing. Tests are fail with error message:
```
TypeError: _reactNative.NetInfo.getConnectionInfo is not a function
```
And cleaned code in this files for unified code styles.

Run test with usage of `NetInfo.getConnectionInfo()`

[GENERAL] [BUGFIX] [jest/setup.js] - Fix Jest mocks for NetInfo module
Closes https://github.com/facebook/react-native/pull/16722

Differential Revision: D6298133

Pulled By: hramos

fbshipit-source-id: 589cf6fed93965e7a09823015f2793f5c68a9c3b
This commit is contained in:
Tim Wang 2017-11-10 09:56:38 -08:00 committed by Facebook Github Bot
parent 58c3bc4901
commit 7fb3a9229d
1 changed files with 13 additions and 5 deletions

View File

@ -162,7 +162,7 @@ const mockNativeModules = {
},
ImageLoader: {
getSize: jest.fn(
(url) => new Promise(() => ({width: 320, height: 240}))
(url) => Promise.resolve({width: 320, height: 240})
),
prefetchImage: jest.fn(),
},
@ -179,11 +179,11 @@ const mockNativeModules = {
Linking: {
openURL: jest.fn(),
canOpenURL: jest.fn(
() => new Promise((resolve) => resolve(true))
() => Promise.resolve(true)
),
addEventListener: jest.fn(),
getInitialURL: jest.fn(
() => new Promise((resolve) => resolve())
() => Promise.resolve()
),
removeEventListener: jest.fn(),
},
@ -195,15 +195,23 @@ const mockNativeModules = {
ModalFullscreenViewManager: {},
NetInfo: {
fetch: jest.fn(
() => new Promise((resolve) => resolve())
() => Promise.resolve()
),
getConnectionInfo: jest.fn(
() => Promise.resolve()
),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
isConnected: {
fetch: jest.fn(
() => new Promise((resolve) => resolve())
() => Promise.resolve()
),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
},
isConnectionExpensive: jest.fn(
() => Promise.resolve()
),
},
Networking: {
sendRequest: jest.fn(),