From a868bd7005bace97f6f8248038f428498ad8aba7 Mon Sep 17 00:00:00 2001 From: Dustin Schie Date: Sun, 22 Nov 2020 22:40:07 -0500 Subject: [PATCH] feat(jest/react-native-device-info-mock): adding rest of mocks (#1132) adds remaining mocks --- jest/react-native-device-info-mock.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jest/react-native-device-info-mock.js b/jest/react-native-device-info-mock.js index 3634d2653..43abf2daf 100755 --- a/jest/react-native-device-info-mock.js +++ b/jest/react-native-device-info-mock.js @@ -8,6 +8,10 @@ const [arrayFnAsync, arrayFnSync] = makeFns([]); const [booleanFnAsync, booleanFnSync] = makeFns(false); const [objectFnAsync, objectFnSync] = makeFns({}); +const numberAsyncHookResultHook = () => jest.fn(() => ({ loading: false, result: -1 })); +const booleanAsyncHookResultHook = () => jest.fn(() => ({ loading: false, result: false })); +const stringAsyncHookResultHook = () => jest.fn(() => ({ loading: false, result: 'unknown' })); + const diMock = { getAndroidId: stringFnAsync(), getAndroidIdSync: stringFnSync(), @@ -92,9 +96,13 @@ const diMock = { getUserAgentSync: stringFnSync(), hasSystemFeature: booleanFnAsync(), hasSystemFeatureSync: booleanFnSync(), + hasGms: booleanFnAsync(), + hasGmsSync: booleanFnSync(), + hasHms: booleanFnAsync(), + hasHmsSync: booleanFnSync(), isAirplaneMode: booleanFnAsync(), isAirplaneModeSync: booleanFnSync(), - isBatteryCharging: booleanFnAsync(), + isBatteryCharging: booleanFnAsync(),, isBatteryChargingSync: booleanFnSync(), isCameraPresent: booleanFnSync(), isCameraPresentSync: booleanFnSync(), @@ -133,7 +141,15 @@ const diMock = { supported64BitAbisSync: arrayFnSync(), supportedAbis: arrayFnAsync(), supportedAbisSync: arrayFnSync(), - // TO DO: add hook mocks ? + useBatteryLevel: numberFnSync(), + useBatteryLevelIsLow: numberFnSync(), + usePowerState: objectFnSync(), + useIsHeadphonesConnected: booleanAsyncHookResultHook(), + useFirstInstallTime: numberAsyncHookResultHook(), + useDeviceName: stringAsyncHookResultHook(), + useHasSystemFeature: booleanAsyncHookResultHook(), + useIsEmulator: booleanAsyncHookResultHook(), + useManufacturer: stringAsyncHookResultHook(), }; module.exports = diMock;