@@ -346,15 +346,61 @@ function firebaseAppTests(
346
346
expect ( firebase . apps . length ) . to . eq ( 2 ) ;
347
347
} ) ;
348
348
349
- it ( 'duplicate DEFAULT initialize is an error.' , ( ) => {
350
- firebase . initializeApp ( { } ) ;
351
- expect ( ( ) => firebase . initializeApp ( { } ) ) . throws ( / \[ D E F A U L T \] .* e x i s t s / i) ;
349
+ it ( 'initializeApp can be called more than once and returns the same instance if the options and config are the same' , ( ) => {
350
+ const app = firebase . initializeApp (
351
+ {
352
+ apiKey : 'test1'
353
+ } ,
354
+ { automaticDataCollectionEnabled : true }
355
+ ) ;
356
+ expect (
357
+ firebase . initializeApp (
358
+ {
359
+ apiKey : 'test1'
360
+ } ,
361
+ { automaticDataCollectionEnabled : true }
362
+ )
363
+ ) . to . equal ( app ) ;
364
+ } ) ;
365
+
366
+ it ( 'duplicate DEFAULT initialize with different options is an error.' , ( ) => {
367
+ firebase . initializeApp ( { apiKey : 'key1' } ) ;
368
+ expect ( ( ) => firebase . initializeApp ( { apiKey : 'key2' } ) ) . throws (
369
+ / \[ D E F A U L T \] .* e x i s t s / i
370
+ ) ;
371
+ } ) ;
372
+
373
+ it ( 'duplicate named App initialize with different options is an error.' , ( ) => {
374
+ firebase . initializeApp ( { apiKey : 'key1' , appId : 'id' } , 'abc' ) ;
375
+ expect ( ( ) => firebase . initializeApp ( { apiKey : 'key1' } , 'abc' ) ) . throws (
376
+ / ' a b c ' .* e x i s t s / i
377
+ ) ;
352
378
} ) ;
353
379
354
- it ( 'duplicate named App initialize is an error.' , ( ) => {
355
- firebase . initializeApp ( { } , 'abc' ) ;
380
+ it ( 'duplicate DEFAULT initialize with different config is an error.' , ( ) => {
381
+ firebase . initializeApp (
382
+ { apiKey : 'key1' } ,
383
+ { automaticDataCollectionEnabled : true }
384
+ ) ;
385
+ expect ( ( ) =>
386
+ firebase . initializeApp (
387
+ { apiKey : 'key1' } ,
388
+ { automaticDataCollectionEnabled : false }
389
+ )
390
+ ) . throws ( / \[ D E F A U L T \] .* e x i s t s / i) ;
391
+ } ) ;
356
392
357
- expect ( ( ) => firebase . initializeApp ( { } , 'abc' ) ) . throws ( / ' a b c ' .* e x i s t s / i) ;
393
+ it ( 'duplicate named App initialize with different config is an error.' , ( ) => {
394
+ firebase . initializeApp (
395
+ { apiKey : 'key1' } ,
396
+ { name : 'abc' , automaticDataCollectionEnabled : true }
397
+ ) ;
398
+ expect ( ( ) =>
399
+ firebase . initializeApp (
400
+ { apiKey : 'key1' } ,
401
+ { name : 'abc' , automaticDataCollectionEnabled : false }
402
+ )
403
+ ) . throws ( / ' a b c ' .* e x i s t s / i) ;
358
404
} ) ;
359
405
360
406
it ( 'automaticDataCollectionEnabled is `false` by default' , ( ) => {
0 commit comments