Skip to content

Commit

Permalink
feat(jest/react-native-device-info-mock): adding rest of mocks (#1132)
Browse files Browse the repository at this point in the history
adds remaining mocks
  • Loading branch information
schie committed Nov 23, 2020
1 parent c99bd5e commit a868bd7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions jest/react-native-device-info-mock.js
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;

0 comments on commit a868bd7

Please sign in to comment.