1
1
import { User } from 'firebase/app' ;
2
2
import { Observable , Subject } from 'rxjs' ;
3
- import { inject , TestBed } from '@angular/core/testing' ;
3
+ import { TestBed } from '@angular/core/testing' ;
4
4
import { AngularFireModule , FIREBASE_APP_NAME , FIREBASE_OPTIONS , FirebaseApp } from '@angular/fire' ;
5
5
import { AngularFireAuth , AngularFireAuthModule } from './public_api' ;
6
6
import { COMMON_CONFIG } from '../test-config' ;
7
- import { skip , take } from 'rxjs/operators' ;
8
7
import 'firebase/auth' ;
9
8
import { rando } from '../firestore/utils.spec' ;
10
9
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
-
19
10
const firebaseUser = {
20
11
uid : '12345' ,
21
12
providerData : [ { displayName : 'jeffbcrossyface' } ]
@@ -24,7 +15,6 @@ const firebaseUser = {
24
15
describe ( 'AngularFireAuth' , ( ) => {
25
16
let app : FirebaseApp ;
26
17
let afAuth : AngularFireAuth ;
27
- let authSpy : jasmine . Spy ;
28
18
let mockAuthState : Subject < User > ;
29
19
30
20
beforeEach ( ( ) => {
@@ -34,10 +24,9 @@ describe('AngularFireAuth', () => {
34
24
AngularFireAuthModule
35
25
]
36
26
} ) ;
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 ) ;
41
30
42
31
mockAuthState = new Subject < User > ( ) ;
43
32
// @ts -ignore
@@ -60,11 +49,11 @@ describe('AngularFireAuth', () => {
60
49
} ) ;
61
50
ngZone . run ( ( ) => {
62
51
const subs = [
63
- afAuth . authState . subscribe ( user => {
52
+ afAuth . authState . subscribe ( ( ) => {
64
53
expect ( Zone . current . name ) . toBe ( 'ngZone' ) ;
65
54
done ( ) ;
66
55
} , done . fail ) ,
67
- afAuth . authState . subscribe ( user => {
56
+ afAuth . authState . subscribe ( ( ) => {
68
57
expect ( Zone . current . name ) . toBe ( 'ngZone' ) ;
69
58
done ( ) ;
70
59
} , done . fail )
@@ -89,7 +78,7 @@ describe('AngularFireAuth', () => {
89
78
// Check that the first value is null and second is the auth user
90
79
const subs = afAuth . authState . subscribe ( user => {
91
80
if ( count === 0 ) {
92
- expect ( user ) . toBe ( null ! ) ;
81
+ expect ( user ) . toBe ( null ) ;
93
82
count = count + 1 ;
94
83
mockAuthState . next ( firebaseUser ) ;
95
84
} else {
@@ -98,7 +87,7 @@ describe('AngularFireAuth', () => {
98
87
done ( ) ;
99
88
}
100
89
} , done , done . fail ) ;
101
- mockAuthState . next ( null ! ) ;
90
+ mockAuthState . next ( null ) ;
102
91
} ) ;
103
92
104
93
it ( 'should emit auth updates through idToken' , ( done : any ) => {
@@ -107,7 +96,7 @@ describe('AngularFireAuth', () => {
107
96
// Check that the first value is null and second is the auth user
108
97
const subs = afAuth . idToken . subscribe ( user => {
109
98
if ( count === 0 ) {
110
- expect ( user ) . toBe ( null ! ) ;
99
+ expect ( user ) . toBe ( null ) ;
111
100
count = count + 1 ;
112
101
mockAuthState . next ( firebaseUser ) ;
113
102
} else {
@@ -116,7 +105,7 @@ describe('AngularFireAuth', () => {
116
105
done ( ) ;
117
106
}
118
107
} , done , done . fail ) ;
119
- mockAuthState . next ( null ! ) ;
108
+ mockAuthState . next ( null ) ;
120
109
} ) ;
121
110
122
111
} ) ;
@@ -138,10 +127,9 @@ describe('AngularFireAuth with different app', () => {
138
127
{ provide : FIREBASE_OPTIONS , useValue : COMMON_CONFIG }
139
128
]
140
129
} ) ;
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 ) ;
145
133
} ) ;
146
134
147
135
afterEach ( ( ) => {
0 commit comments