@@ -31,7 +31,7 @@ import {
31
31
import { isNode } from '@firebase/util' ;
32
32
33
33
import { expect } from 'chai' ;
34
- import { inMemoryPersistence } from '../../../internal' ;
34
+ import { browserLocalPersistence , browserSessionPersistence , inMemoryPersistence } from '../../../internal' ;
35
35
36
36
import { AuthInternal } from '../../model/auth' ;
37
37
import {
@@ -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 ;
@@ -209,9 +210,49 @@ describe('core/auth/initialize', () => {
209
210
expect ( auth . _isInitialized ) . to . be . false ;
210
211
} ) ;
211
212
212
- it ( 'should throw if called more than once' , ( ) => {
213
- initializeAuth ( fakeApp ) ;
214
- expect ( ( ) => initializeAuth ( fakeApp ) ) . to . throw ( ) ;
213
+ it ( 'should not throw if called again with same (no) params' , ( ) => {
214
+ const auth = initializeAuth ( fakeApp ) ;
215
+ expect ( initializeAuth ( fakeApp ) ) . to . equal ( auth ) ;
216
+ } ) ;
217
+
218
+ it ( 'should not throw if called again with same params' , ( ) => {
219
+ const auth = initializeAuth ( fakeApp , {
220
+ errorMap : prodErrorMap ,
221
+ persistence : browserSessionPersistence ,
222
+ popupRedirectResolver : fakePopupRedirectResolver
223
+ } ) ;
224
+ expect ( initializeAuth ( fakeApp , {
225
+ errorMap : prodErrorMap ,
226
+ persistence : browserSessionPersistence ,
227
+ popupRedirectResolver : fakePopupRedirectResolver
228
+ } ) ) . to . equal ( auth ) ;
229
+ } ) ;
230
+
231
+ it ( 'should throw if called again with different params (popupRedirectResolver)' , ( ) => {
232
+ initializeAuth ( fakeApp , {
233
+ popupRedirectResolver : fakePopupRedirectResolver
234
+ } ) ;
235
+ expect ( ( ) => initializeAuth ( fakeApp , {
236
+ popupRedirectResolver : undefined
237
+ } ) ) . to . throw ( ) ;
238
+ } ) ;
239
+
240
+ it ( 'should throw if called again with different params (errorMap)' , ( ) => {
241
+ initializeAuth ( fakeApp , {
242
+ errorMap : prodErrorMap
243
+ } ) ;
244
+ expect ( ( ) => initializeAuth ( fakeApp , {
245
+ errorMap : debugErrorMap
246
+ } ) ) . to . throw ( ) ;
247
+ } ) ;
248
+
249
+ it ( 'should throw if called again with different params (persistence)' , ( ) => {
250
+ initializeAuth ( fakeApp , {
251
+ persistence : [ browserLocalPersistence , browserSessionPersistence ]
252
+ } ) ;
253
+ expect ( ( ) => initializeAuth ( fakeApp , {
254
+ persistence : [ browserSessionPersistence , browserLocalPersistence ]
255
+ } ) ) . to . throw ( ) ;
215
256
} ) ;
216
257
} ) ;
217
258
} ) ;
0 commit comments