Sharad Pawar
Sharad Pawar

Reputation: 286

TypeError: _reactNativePushNotification.default.localNotificationSchedule is not a function while writing unit test

I am not able to write unit test for the following code

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 })
}

Upvotes: 1

Views: 1854

Answers (2)

Sharad Pawar
Sharad Pawar

Reputation: 286

Here is the way to mock

jest.mock('react-native-push-notification', () => ({
  configure: jest.fn(),
  onRegister: jest.fn(),
  onNotification: jest.fn(),
  addEventListener: jest.fn(),
  requestPermissions: jest.fn()
}))

Upvotes: 2

Anurag Chutani
Anurag Chutani

Reputation: 595

Please add native code for notification module.

For reference:

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

Upvotes: 0

Related Questions