@@ -29,18 +29,21 @@ import { Endpoint } from '../../api';
2929import { UserInternal } from '../../model/user' ;
3030import { _castAuth } from './auth_impl' ;
3131import { connectAuthEmulator } from './emulator' ;
32+ import { FetchProvider } from '../util/fetch_provider' ;
3233
3334use ( sinonChai ) ;
3435use ( chaiAsPromised ) ;
3536
36- describe ( 'core/auth/emulator' , ( ) => {
37+ describe . only ( 'core/auth/emulator' , ( ) => {
3738 let auth : TestAuth ;
3839 let user : UserInternal ;
3940 let normalEndpoint : fetch . Route ;
4041 let emulatorEndpoint : fetch . Route ;
42+ let spy : sinon . SinonSpy ;
4143
4244 beforeEach ( async ( ) => {
4345 auth = await testAuth ( ) ;
46+ spy = sinon . spy ( FetchProvider . fetch ( ) ) ;
4447 user = testUser ( _castAuth ( auth ) , 'uid' , 'email' , true ) ;
4548 fetch . setUp ( ) ;
4649 normalEndpoint = mockEndpoint ( Endpoint . DELETE_ACCOUNT , { } ) ;
@@ -93,6 +96,16 @@ describe('core/auth/emulator', () => {
9396 'auth/emulator-config-failed'
9497 ) ;
9598 } ) ;
99+ it . only ( 'sends the proper value' , async ( ) => {
100+ expect ( ( ) => connectAuthEmulator ( auth , 'http://127.0.0.1:2020' ) ) . to . not
101+ . throw ;
102+ await user . delete ( ) ;
103+ expect ( spy ) . to . have . been . called ;
104+ expect ( ( ) => connectAuthEmulator ( auth , 'http://127.0.0.1:2021' ) ) . to . throw (
105+ FirebaseError ,
106+ 'auth/emulator-config-failed'
107+ ) ;
108+ } ) ;
96109
97110 it ( 'subsequent calls update the endpoint appropriately' , async ( ) => {
98111 connectAuthEmulator ( auth , 'http://127.0.0.1:2021' ) ;
@@ -111,6 +124,23 @@ describe('core/auth/emulator', () => {
111124 } ) ;
112125 } ) ;
113126
127+ it ( 'subsequent calls update the endpoint appropriately' , async ( ) => {
128+ connectAuthEmulator ( auth , 'http://127.0.0.1:2021' ) ;
129+ expect ( auth . emulatorConfig ) . to . eql ( {
130+ protocol : 'http' ,
131+ host : '127.0.0.1' ,
132+ port : 2021 ,
133+ options : { disableWarnings : false }
134+ } ) ;
135+ connectAuthEmulator ( auth , 'http://127.0.0.1:2020' ) ;
136+ expect ( auth . emulatorConfig ) . to . eql ( {
137+ protocol : 'http' ,
138+ host : '127.0.0.1' ,
139+ port : 2020 ,
140+ options : { disableWarnings : false }
141+ } ) ;
142+ } ) ;
143+
114144 it ( 'updates the endpoint appropriately' , async ( ) => {
115145 connectAuthEmulator ( auth , 'http://127.0.0.1:2020' ) ;
116146 await user . delete ( ) ;
0 commit comments