Created
November 1, 2018 21:26
-
-
Save maml/379ee6adfda02a28afb4c6d957f7cc86 to your computer and use it in GitHub Desktop.
react-native-firebase jest mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jest.mock('react-native-firebase', () => { | |
return { | |
admob: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
analytics: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
auth: jest.fn(() => { | |
return { | |
hasPermission: jest.fn(() => Promise.resolve(true)), | |
subscribeToTopic: jest.fn(), | |
unsubscribeFromTopic: jest.fn(), | |
requestPermission: jest.fn(() => Promise.resolve(true)), | |
getToken: jest.fn(() => Promise.resolve('RN-Firebase-Token')) | |
} | |
}), | |
crashlytics: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
firestore: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
perf: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
links: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
database: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
config: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
storage: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
iid: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}), | |
messaging: jest.fn(() => { | |
return { | |
hasPermission: jest.fn(() => Promise.resolve(true)), | |
subscribeToTopic: jest.fn(), | |
unsubscribeFromTopic: jest.fn(), | |
requestPermission: jest.fn(() => Promise.resolve(true)), | |
getToken: jest.fn(() => Promise.resolve('RN-Firebase-Token')) | |
} | |
}), | |
notifications: jest.fn(() => { | |
return { | |
onNotification: jest.fn(), | |
onNotificationDisplayed: jest.fn() | |
} | |
}) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
"jest": { | |
"preset": "react-native", | |
"setupTestFrameworkScriptFile": "./jest.mock.rn-firebase", | |
"automock": false | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment