Skip to content

Commit

Permalink
fix(auth): set the passed settings individually (#2833)
Browse files Browse the repository at this point in the history
`auth.settings` is readonly, need to assign each setting key individually.
  • Loading branch information
KingDarBoja authored May 18, 2021
1 parent 8d69c9d commit 984803d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import firebase from 'firebase/app';
import { Observable, Subject } from 'rxjs';
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFireAuth, AngularFireAuthModule, SETTINGS } from '@angular/fire/auth';
import { COMMON_CONFIG } from '../test-config';
import 'firebase/auth';
import { rando } from '../firestore/utils.spec';
Expand All @@ -22,6 +22,9 @@ describe('AngularFireAuth', () => {
imports: [
AngularFireModule.initializeApp(COMMON_CONFIG, rando()),
AngularFireAuthModule
],
providers: [
{ provide: SETTINGS, useValue: { appVerificationDisabledForTesting: true } }
]
});

Expand Down Expand Up @@ -72,6 +75,11 @@ describe('AngularFireAuth', () => {
expect(afAuth.app).toBeDefined();
});

it('should have disabled app verification for testing', async () => {
const app = await afAuth.app;
expect(app.auth().settings.appVerificationDisabledForTesting).toBe(true);
});

it('should emit auth updates through authState', (done: any) => {
let count = 0;

Expand Down
4 changes: 3 additions & 1 deletion src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ export class AngularFireAuth {
auth.useDeviceLanguage();
}
if (settings) {
auth.settings = settings;
for (const [k, v] of Object.entries(settings)) {
auth.settings[k] = v;
}
}
if (persistence) {
auth.setPersistence(persistence);
Expand Down

0 comments on commit 984803d

Please sign in to comment.