@@ -26,6 +26,7 @@ import {
26
26
AuthProvider ,
27
27
Persistence as PersistencePublic ,
28
28
PopupRedirectResolver ,
29
+ TenantConfig ,
29
30
UserCredential
30
31
} from '../../model/public_types' ;
31
32
import { isNode } from '@firebase/util' ;
@@ -51,6 +52,7 @@ import { ClientPlatform, _getClientVersion } from '../util/version';
51
52
import { initializeAuth } from './initialize' ;
52
53
import { registerAuth } from './register' ;
53
54
import { debugErrorMap , prodErrorMap } from '../errors' ;
55
+ import { DefaultConfig } from './auth_impl' ;
54
56
55
57
describe ( 'core/auth/initialize' , ( ) => {
56
58
let fakeApp : FirebaseApp ;
@@ -132,6 +134,8 @@ describe('core/auth/initialize', () => {
132
134
const fakePopupRedirectResolver : PopupRedirectResolver =
133
135
FakePopupRedirectResolver ;
134
136
137
+ const fakeTenantConfig : TenantConfig = { 'location' : "us" , 'tenantId' : "tenant-1" } ;
138
+
135
139
before ( ( ) => {
136
140
registerAuth ( ClientPlatform . BROWSER ) ;
137
141
} ) ;
@@ -202,6 +206,15 @@ describe('core/auth/initialize', () => {
202
206
) ;
203
207
} ) ;
204
208
209
+ it ( 'should set TenantConfig' , async ( ) => {
210
+ const auth = initializeAuth ( fakeApp , {
211
+ tenantConfig : fakeTenantConfig
212
+ } ) as AuthInternal ;
213
+ await auth . _initializationPromise ;
214
+
215
+ expect ( auth . config . apiHost ) . equal ( DefaultConfig . REGIONAL_API_HOST ) ;
216
+ } ) ;
217
+
205
218
it ( 'should abort initialization if deleted synchronously' , async ( ) => {
206
219
const auth = initializeAuth ( fakeApp , {
207
220
popupRedirectResolver : fakePopupRedirectResolver
@@ -221,13 +234,15 @@ describe('core/auth/initialize', () => {
221
234
const auth = initializeAuth ( fakeApp , {
222
235
errorMap : prodErrorMap ,
223
236
persistence : fakeSessionPersistence ,
224
- popupRedirectResolver : fakePopupRedirectResolver
237
+ popupRedirectResolver : fakePopupRedirectResolver ,
238
+ tenantConfig : fakeTenantConfig
225
239
} ) ;
226
240
expect (
227
241
initializeAuth ( fakeApp , {
228
242
errorMap : prodErrorMap ,
229
243
persistence : fakeSessionPersistence ,
230
- popupRedirectResolver : fakePopupRedirectResolver
244
+ popupRedirectResolver : fakePopupRedirectResolver ,
245
+ tenantConfig : fakeTenantConfig
231
246
} )
232
247
) . to . equal ( auth ) ;
233
248
} ) ;
@@ -264,5 +279,16 @@ describe('core/auth/initialize', () => {
264
279
} )
265
280
) . to . throw ( ) ;
266
281
} ) ;
282
+
283
+ it ( 'should throw if called again with different params (TenantConfig)' , ( ) => {
284
+ initializeAuth ( fakeApp , {
285
+ tenantConfig : fakeTenantConfig
286
+ } ) ;
287
+ expect ( ( ) =>
288
+ initializeAuth ( fakeApp , {
289
+ tenantConfig : undefined
290
+ } )
291
+ ) . to . throw ( ) ;
292
+ } ) ;
267
293
} ) ;
268
294
} ) ;
0 commit comments