@@ -29,18 +29,21 @@ import { Endpoint } from '../../api';
29
29
import { UserInternal } from '../../model/user' ;
30
30
import { _castAuth } from './auth_impl' ;
31
31
import { connectAuthEmulator } from './emulator' ;
32
+ import { FetchProvider } from '../util/fetch_provider' ;
32
33
33
34
use ( sinonChai ) ;
34
35
use ( chaiAsPromised ) ;
35
36
36
- describe ( 'core/auth/emulator' , ( ) => {
37
+ describe . only ( 'core/auth/emulator' , ( ) => {
37
38
let auth : TestAuth ;
38
39
let user : UserInternal ;
39
40
let normalEndpoint : fetch . Route ;
40
41
let emulatorEndpoint : fetch . Route ;
42
+ let spy : sinon . SinonSpy ;
41
43
42
44
beforeEach ( async ( ) => {
43
45
auth = await testAuth ( ) ;
46
+ spy = sinon . spy ( FetchProvider . fetch ( ) ) ;
44
47
user = testUser ( _castAuth ( auth ) , 'uid' , 'email' , true ) ;
45
48
fetch . setUp ( ) ;
46
49
normalEndpoint = mockEndpoint ( Endpoint . DELETE_ACCOUNT , { } ) ;
@@ -93,6 +96,16 @@ describe('core/auth/emulator', () => {
93
96
'auth/emulator-config-failed'
94
97
) ;
95
98
} ) ;
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
+ } ) ;
96
109
97
110
it ( 'subsequent calls update the endpoint appropriately' , async ( ) => {
98
111
connectAuthEmulator ( auth , 'http://127.0.0.1:2021' ) ;
@@ -111,6 +124,23 @@ describe('core/auth/emulator', () => {
111
124
} ) ;
112
125
} ) ;
113
126
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
+
114
144
it ( 'updates the endpoint appropriately' , async ( ) => {
115
145
connectAuthEmulator ( auth , 'http://127.0.0.1:2020' ) ;
116
146
await user . delete ( ) ;
0 commit comments