Skip to content

Instantly share code, notes, and snippets.

@choipd
Created August 7, 2018 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choipd/cc51a2edf73b2919326f1f04d3ac328e to your computer and use it in GitHub Desktop.
Save choipd/cc51a2edf73b2919326f1f04d3ac328e to your computer and use it in GitHub Desktop.
react-native-firebase mock
jest.mock('react-native-firebase', () => {
return {
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('myMockToken'))
};
}),
notifications: jest.fn(() => {
return {
onNotification: jest.fn(),
onNotificationDisplayed: jest.fn()
};
}),
firestore: jest.fn(() => {
return {
batch: jest.fn(() => {
return {
commit: jest.fn(),
set: jest.fn(),
update: jest.fn(),
delete: jest.fn()
}
}),
collection: jest.fn(),
doc: jest.fn(),
settings: jest.fn(),
runTransaction: jest.fn(),
}
})
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment