@@ -28,6 +28,7 @@ import * as utils from './utils';
2828import * as mocks from '../resources/mocks' ;
2929
3030import * as firebaseAdmin from '../../src/index' ;
31+ import { ApplicationDefaultCredential } from '../../src/auth/credential' ;
3132
3233chai . should ( ) ;
3334chai . use ( chaiAsPromised ) ;
@@ -55,25 +56,19 @@ describe('Firebase', () => {
5556 } ) ;
5657
5758 describe ( '#initializeApp()' , ( ) => {
58- const invalidOptions = [ null , NaN , 0 , 1 , true , false , '' , 'a' , [ ] , { } , _ . noop ] ;
59- invalidOptions . forEach ( ( invalidOption ) => {
59+ const invalidOptions = [ null , NaN , 0 , 1 , true , false , '' , 'a' , [ ] , _ . noop ] ;
60+ invalidOptions . forEach ( ( invalidOption : any ) => {
6061 it ( 'should throw given invalid options object: ' + JSON . stringify ( invalidOption ) , ( ) => {
6162 expect ( ( ) => {
6263 firebaseAdmin . initializeApp ( invalidOption ) ;
6364 } ) . to . throw ( 'Invalid Firebase app options' ) ;
6465 } ) ;
6566 } ) ;
6667
67- it ( 'should throw given an options object that does not contain any of the required keys' , ( ) => {
68- expect ( ( ) => {
69- firebaseAdmin . initializeApp ( { a : 1 , b : true } as any ) ;
70- } ) . to . throw ( 'Invalid Firebase app options' ) ;
71- } ) ;
72-
73- it ( 'should throw given an options object containing no "credential" key' , ( ) => {
74- expect ( ( ) => {
75- firebaseAdmin . initializeApp ( mocks . appOptionsNoAuth ) ;
76- } ) . to . throw ( 'Invalid Firebase app options' ) ;
68+ it ( 'should use application default credentials when no credentials are explicitly specified' , ( ) => {
69+ const app = firebaseAdmin . initializeApp ( mocks . appOptionsNoAuth ) ;
70+ expect ( app . options ) . to . have . property ( 'credential' ) ;
71+ expect ( app . options . credential ) . to . be . instanceOf ( ApplicationDefaultCredential ) ;
7772 } ) ;
7873
7974 it ( 'should not modify the provided options object' , ( ) => {
0 commit comments