Permalink
Browse files

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 #16722

Differential Revision: D6298133

Pulled By: hramos

fbshipit-source-id: 589cf6fed93965e7a09823015f2793f5c68a9c3b
  • Loading branch information...
timwangdev authored and facebook-github-bot committed Nov 10, 2017
1 parent 58c3bc4 commit 7fb3a9229df52bd45076470d059f245a8147cd2a
Showing with 13 additions and 5 deletions.
  1. +13 −5 jest/setup.js
@@ -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(),

0 comments on commit 7fb3a92

Please sign in to comment.