1

我无法为以下代码编写单元测试

import PushNotification from 'react-native-push-notification'
import { timeZoneForNotification } from '../Assets/Constants/constants'
import firebase from 'react-native-firebase'
export const scheduleNotification = ({ 
    title = timeZoneForNotification.title, 
    message 
 },
  date
) => {
  PushNotification.localNotificationSchedule({ title, message, date })
}
4

2 回答 2

1

这是模拟的方式

jest.mock('react-native-push-notification', () => ({
  configure: jest.fn(),
  onRegister: jest.fn(),
  onNotification: jest.fn(),
  addEventListener: jest.fn(),
  requestPermissions: jest.fn()
}))
于 2020-09-18T10:24:33.477 回答
0

请为通知模块添加本机代码。

以供参考:

https://github.com/react-native-community/react-native-push-notification-ios#appdelegatem

于 2019-09-18T08:04:52.893 回答