@@ -50,6 +50,7 @@ import {
50
50
import { ClientPlatform , _getClientVersion } from '../util/version' ;
51
51
import { initializeAuth } from './initialize' ;
52
52
import { registerAuth } from './register' ;
53
+ import { debugErrorMap , prodErrorMap } from '../errors' ;
53
54
54
55
describe ( 'core/auth/initialize' , ( ) => {
55
56
let fakeApp : FirebaseApp ;
@@ -127,7 +128,8 @@ describe('core/auth/initialize', () => {
127
128
}
128
129
}
129
130
130
- const fakePopupRedirectResolver : PopupRedirectResolver = FakePopupRedirectResolver ;
131
+ const fakePopupRedirectResolver : PopupRedirectResolver =
132
+ FakePopupRedirectResolver ;
131
133
132
134
before ( ( ) => {
133
135
registerAuth ( ClientPlatform . BROWSER ) ;
@@ -203,15 +205,63 @@ describe('core/auth/initialize', () => {
203
205
const auth = initializeAuth ( fakeApp , {
204
206
popupRedirectResolver : fakePopupRedirectResolver
205
207
} ) as AuthInternal ;
206
- await ( ( auth as unknown ) as _FirebaseService ) . _delete ( ) ;
208
+ await ( auth as unknown as _FirebaseService ) . _delete ( ) ;
207
209
await auth . _initializationPromise ;
208
210
209
211
expect ( auth . _isInitialized ) . to . be . false ;
210
212
} ) ;
211
213
212
- it ( 'should throw if called more than once' , ( ) => {
213
- initializeAuth ( fakeApp ) ;
214
- expect ( ( ) => initializeAuth ( fakeApp ) ) . to . throw ( ) ;
214
+ it ( 'should not throw if called again with same (no) params' , ( ) => {
215
+ const auth = initializeAuth ( fakeApp ) ;
216
+ expect ( initializeAuth ( fakeApp ) ) . to . equal ( auth ) ;
217
+ } ) ;
218
+
219
+ it ( 'should not throw if called again with same params' , ( ) => {
220
+ const auth = initializeAuth ( fakeApp , {
221
+ errorMap : prodErrorMap ,
222
+ persistence : fakeSessionPersistence ,
223
+ popupRedirectResolver : fakePopupRedirectResolver
224
+ } ) ;
225
+ expect (
226
+ initializeAuth ( fakeApp , {
227
+ errorMap : prodErrorMap ,
228
+ persistence : fakeSessionPersistence ,
229
+ popupRedirectResolver : fakePopupRedirectResolver
230
+ } )
231
+ ) . to . equal ( auth ) ;
232
+ } ) ;
233
+
234
+ it ( 'should throw if called again with different params (popupRedirectResolver)' , ( ) => {
235
+ initializeAuth ( fakeApp , {
236
+ popupRedirectResolver : fakePopupRedirectResolver
237
+ } ) ;
238
+ expect ( ( ) =>
239
+ initializeAuth ( fakeApp , {
240
+ popupRedirectResolver : undefined
241
+ } )
242
+ ) . to . throw ( ) ;
243
+ } ) ;
244
+
245
+ it ( 'should throw if called again with different params (errorMap)' , ( ) => {
246
+ initializeAuth ( fakeApp , {
247
+ errorMap : prodErrorMap
248
+ } ) ;
249
+ expect ( ( ) =>
250
+ initializeAuth ( fakeApp , {
251
+ errorMap : debugErrorMap
252
+ } )
253
+ ) . to . throw ( ) ;
254
+ } ) ;
255
+
256
+ it ( 'should throw if called again with different params (persistence)' , ( ) => {
257
+ initializeAuth ( fakeApp , {
258
+ persistence : [ inMemoryPersistence , fakeSessionPersistence ]
259
+ } ) ;
260
+ expect ( ( ) =>
261
+ initializeAuth ( fakeApp , {
262
+ persistence : [ fakeSessionPersistence , inMemoryPersistence ]
263
+ } )
264
+ ) . to . throw ( ) ;
215
265
} ) ;
216
266
} ) ;
217
267
} ) ;
0 commit comments