mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 16:36:25 +00:00
Summary: `PushNotificationIOS` is a library that makes use of the `PushNotificationManager` native module. This commit adds a jest mock for its native module so that code that uses `PushNotificationIOS` can be tested using jest. In order to enable behaviour in unit tests it is possible to replace or overwrite the mock implementation, see the [jest guide on mocks](https://facebook.github.io/jest/docs/mock-functions.html). By doing something similar to: ```javascript import { NativeModules } from 'react-native'; const { PushNotificationManager } = NativeModules; // mock 'checkPermissions' to return a different value than the default: PushNotificationManager.checkPermissions.mockImplementationOnce((callback) => { // execute callback in next tick to enable async behaviour process.nextTick(() => callback({ alert: false, badge: false, sound: false })); }); // execute unit tests for code that makes use of 'PushNotificationIOS' ``` Closes https://github.com/facebook/react-native/pull/13410 Differential Revision: D5043904 Pulled By: cpojer fbshipit-source-id: 11e73cd215ba6854d06f4ac7a5aea0ab4be26584