-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35552 from JKobrynski/migrateNetInfoMockToTypeScript
[No QA] [TS migration] Migrate 'netinfo.js' mock to TypeScript
- Loading branch information
Showing
3 changed files
with
32 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {NetInfoCellularGeneration, NetInfoStateType} from '@react-native-community/netinfo'; | ||
import type {addEventListener, configure, fetch, NetInfoState, refresh, useNetInfo} from '@react-native-community/netinfo'; | ||
|
||
const defaultState: NetInfoState = { | ||
type: NetInfoStateType.cellular, | ||
isConnected: true, | ||
isInternetReachable: true, | ||
details: { | ||
isConnectionExpensive: true, | ||
cellularGeneration: NetInfoCellularGeneration['3g'], | ||
carrier: 'T-Mobile', | ||
}, | ||
}; | ||
|
||
type NetInfoMock = { | ||
configure: typeof configure; | ||
fetch: typeof fetch; | ||
refresh: typeof refresh; | ||
addEventListener: typeof addEventListener; | ||
useNetInfo: typeof useNetInfo; | ||
}; | ||
|
||
const netInfoMock: NetInfoMock = { | ||
configure: () => {}, | ||
fetch: () => Promise.resolve(defaultState), | ||
refresh: () => Promise.resolve(defaultState), | ||
addEventListener: () => () => {}, | ||
useNetInfo: () => defaultState, | ||
}; | ||
|
||
export default netInfoMock; |