Skip to content

Commit 8ec82a3

Browse files
chore(lint): Clean up auth
1 parent 23e2f1e commit 8ec82a3

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/auth-guard/auth-guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class AngularFireAuthGuard implements CanActivate {
4040
return this.authState.pipe(
4141
take(1),
4242
authPipeFactory(next, state),
43-
map(can => typeof can == 'boolean' ? can : this.router.createUrlTree(can as any[]))
43+
map(can => typeof can === 'boolean' ? can : this.router.createUrlTree(can as any[]))
4444
);
4545
}
4646

src/auth/auth.spec.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import { User } from 'firebase/app';
22
import { Observable, Subject } from 'rxjs';
3-
import { inject, TestBed } from '@angular/core/testing';
3+
import { TestBed } from '@angular/core/testing';
44
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
55
import { AngularFireAuth, AngularFireAuthModule } from './public_api';
66
import { COMMON_CONFIG } from '../test-config';
7-
import { skip, take } from 'rxjs/operators';
87
import 'firebase/auth';
98
import { rando } from '../firestore/utils.spec';
109

11-
function authTake(auth: Observable<any>, count: number): Observable<any> {
12-
return take.call(auth, 1);
13-
}
14-
15-
function authSkip(auth: Observable<any>, count: number): Observable<any> {
16-
return skip.call(auth, 1);
17-
}
18-
1910
const firebaseUser = {
2011
uid: '12345',
2112
providerData: [{ displayName: 'jeffbcrossyface' }]
@@ -24,7 +15,6 @@ const firebaseUser = {
2415
describe('AngularFireAuth', () => {
2516
let app: FirebaseApp;
2617
let afAuth: AngularFireAuth;
27-
let authSpy: jasmine.Spy;
2818
let mockAuthState: Subject<User>;
2919

3020
beforeEach(() => {
@@ -34,10 +24,9 @@ describe('AngularFireAuth', () => {
3424
AngularFireAuthModule
3525
]
3626
});
37-
inject([FirebaseApp, AngularFireAuth], (app_: FirebaseApp, _auth: AngularFireAuth) => {
38-
app = app_;
39-
afAuth = _auth;
40-
})();
27+
28+
app = TestBed.inject(FirebaseApp);
29+
afAuth = TestBed.inject(AngularFireAuth);
4130

4231
mockAuthState = new Subject<User>();
4332
// @ts-ignore
@@ -60,11 +49,11 @@ describe('AngularFireAuth', () => {
6049
});
6150
ngZone.run(() => {
6251
const subs = [
63-
afAuth.authState.subscribe(user => {
52+
afAuth.authState.subscribe(() => {
6453
expect(Zone.current.name).toBe('ngZone');
6554
done();
6655
}, done.fail),
67-
afAuth.authState.subscribe(user => {
56+
afAuth.authState.subscribe(() => {
6857
expect(Zone.current.name).toBe('ngZone');
6958
done();
7059
}, done.fail)
@@ -89,7 +78,7 @@ describe('AngularFireAuth', () => {
8978
// Check that the first value is null and second is the auth user
9079
const subs = afAuth.authState.subscribe(user => {
9180
if (count === 0) {
92-
expect(user).toBe(null!);
81+
expect(user).toBe(null);
9382
count = count + 1;
9483
mockAuthState.next(firebaseUser);
9584
} else {
@@ -98,7 +87,7 @@ describe('AngularFireAuth', () => {
9887
done();
9988
}
10089
}, done, done.fail);
101-
mockAuthState.next(null!);
90+
mockAuthState.next(null);
10291
});
10392

10493
it('should emit auth updates through idToken', (done: any) => {
@@ -107,7 +96,7 @@ describe('AngularFireAuth', () => {
10796
// Check that the first value is null and second is the auth user
10897
const subs = afAuth.idToken.subscribe(user => {
10998
if (count === 0) {
110-
expect(user).toBe(null!);
99+
expect(user).toBe(null);
111100
count = count + 1;
112101
mockAuthState.next(firebaseUser);
113102
} else {
@@ -116,7 +105,7 @@ describe('AngularFireAuth', () => {
116105
done();
117106
}
118107
}, done, done.fail);
119-
mockAuthState.next(null!);
108+
mockAuthState.next(null);
120109
});
121110

122111
});
@@ -138,10 +127,9 @@ describe('AngularFireAuth with different app', () => {
138127
{ provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG }
139128
]
140129
});
141-
inject([FirebaseApp, AngularFireAuth], (app_: FirebaseApp, _afAuth: AngularFireAuth) => {
142-
app = app_;
143-
afAuth = _afAuth;
144-
})();
130+
131+
app = TestBed.inject(FirebaseApp);
132+
afAuth = TestBed.inject(AngularFireAuth);
145133
});
146134

147135
afterEach(() => {

0 commit comments

Comments
 (0)