Last active
March 18, 2022 06:42
-
-
Save splintor/a470420ac51de66827f2090bec9fb061 to your computer and use it in GitHub Desktop.
getFirebaseToken test on Firebase 8
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
import firebase from 'firebase/app'; | |
import { getFirebaseToken } from './getFirebaseToken'; | |
describe('getFirebaseToken', () => { | |
beforeAll(() => { | |
jest.spyOn(firebase, 'initializeApp').mockImplementation(jest.fn()); | |
jest.spyOn(firebase, 'messaging').mockReturnValue({ getToken: jest.fn() }); | |
}) | |
it('should call firebase.initializeAp and firebase.messaging.getToken', async () => { | |
await getFirebaseToken(); | |
expect(firebase.initializeApp).toHaveBeenCalled(); | |
expect(firebase.messaging().getToken).toHaveBeenCalled(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment