Skip to content

Commit

Permalink
Implement addAuthTokenListener in testing. Fix #2417. (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchenshi authored Dec 10, 2019
1 parent d1f2693 commit 5a880c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/testing/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,17 @@ function initializeApp(
}
const appName = 'app-' + new Date().getTime() + '-' + Math.random();
let app = firebase.initializeApp(appOptions, appName);
// hijacking INTERNAL.getToken to bypass FirebaseAuth and allows specifying of auth headers
if (accessToken) {
const mockAuthComponent = new Component(
'auth-internal',
() =>
({
getToken: async () => ({ accessToken: accessToken }),
getUid: () => null,
addAuthTokenListener: () => {},
addAuthTokenListener: (listener) => {
// Call listener once immediately with predefined accessToken.
listener(accessToken);
},
removeAuthTokenListener: () => {}
} as FirebaseAuthInternal),
ComponentType.PRIVATE
Expand Down

0 comments on commit 5a880c6

Please sign in to comment.