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:
parent
58c3bc4901
commit
7fb3a9229d
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue