@@ -40,6 +40,7 @@ import { createTestComponent } from '../test/util';
40
40
import { Component , ComponentType } from '@firebase/component' ;
41
41
import { Logger } from '@firebase/logger' ;
42
42
import { FirebaseAppImpl } from './firebaseApp' ;
43
+ import { FirebaseServerAppImpl } from './firebaseServerApp' ;
43
44
import { isBrowser } from '@firebase/util' ;
44
45
45
46
declare module '@firebase/component' {
@@ -184,7 +185,7 @@ describe('API tests', () => {
184
185
} ) ;
185
186
186
187
describe ( 'initializeServerApp' , ( ) => {
187
- it ( 'creates FirebaseServerApp with options ' , ( ) => {
188
+ it ( 'creates FirebaseServerApp fails in browsers. ' , ( ) => {
188
189
if ( isBrowser ( ) ) {
189
190
const options = {
190
191
apiKey : 'APIKEY'
@@ -196,7 +197,7 @@ describe('API tests', () => {
196
197
}
197
198
} ) ;
198
199
199
- it ( 'creates FirebaseServerApp with options' , ( ) => {
200
+ it ( 'creates FirebaseServerApp with options' , async ( ) => {
200
201
if ( isBrowser ( ) ) {
201
202
// FirebaseServerApp isn't supported for execution in browser enviornments.
202
203
return ;
@@ -211,9 +212,10 @@ describe('API tests', () => {
211
212
const app = initializeServerApp ( options , serverAppSettings ) ;
212
213
expect ( app ) . to . not . equal ( null ) ;
213
214
expect ( app . automaticDataCollectionEnabled ) . to . be . false ;
215
+ await deleteApp ( app ) ;
214
216
} ) ;
215
217
216
- it ( 'creates FirebaseServerApp with automaticDataCollectionEnabled' , ( ) => {
218
+ it ( 'creates FirebaseServerApp with automaticDataCollectionEnabled' , async ( ) => {
217
219
if ( isBrowser ( ) ) {
218
220
// FirebaseServerApp isn't supported for execution in browser enviornments.
219
221
return ;
@@ -230,9 +232,10 @@ describe('API tests', () => {
230
232
const app = initializeServerApp ( options , serverAppSettings ) ;
231
233
expect ( app ) . to . not . equal ( null ) ;
232
234
expect ( app . automaticDataCollectionEnabled ) . to . be . true ;
235
+ await deleteApp ( app ) ;
233
236
} ) ;
234
237
235
- it ( 'creates FirebaseServerApp with releaseOnDeref' , ( ) => {
238
+ it ( 'creates FirebaseServerApp with releaseOnDeref' , async ( ) => {
236
239
if ( isBrowser ( ) ) {
237
240
// FirebaseServerApp isn't supported for execution in browser enviornments.
238
241
return ;
@@ -247,9 +250,10 @@ describe('API tests', () => {
247
250
const app = initializeServerApp ( options , serverAppSettings ) ;
248
251
expect ( app ) . to . not . equal ( null ) ;
249
252
expect ( app . automaticDataCollectionEnabled ) . to . be . false ;
253
+ await deleteApp ( app ) ;
250
254
} ) ;
251
255
252
- it ( 'creates FirebaseServerApp with FirebaseApp' , ( ) => {
256
+ it ( 'creates FirebaseServerApp with FirebaseApp' , async ( ) => {
253
257
if ( isBrowser ( ) ) {
254
258
// FirebaseServerApp isn't supported for execution in browser enviornments.
255
259
return ;
@@ -266,12 +270,65 @@ describe('API tests', () => {
266
270
automaticDataCollectionEnabled : false
267
271
} ;
268
272
269
- const serverApp = initializeServerApp ( standardApp , serverAppSettings ) ;
270
- expect ( serverApp ) . to . not . equal ( null ) ;
271
- expect ( serverApp . options . apiKey ) . to . equal ( 'test1' ) ;
273
+ const app = initializeServerApp ( standardApp , serverAppSettings ) ;
274
+ expect ( app ) . to . not . equal ( null ) ;
275
+ expect ( app . options . apiKey ) . to . equal ( 'test1' ) ;
276
+ await deleteApp ( app ) ;
272
277
} ) ;
273
278
} ) ;
274
279
280
+ it ( 'create similar FirebaseServerApps does not return the same object' , async ( ) => {
281
+ if ( isBrowser ( ) ) {
282
+ // FirebaseServerApp isn't supported for execution in browser enviornments.
283
+ return ;
284
+ }
285
+
286
+ const options = { apiKey : 'APIKEY' } ;
287
+ const serverAppSettingsOne : FirebaseServerAppSettings = {
288
+ automaticDataCollectionEnabled : false ,
289
+ releaseOnDeref : options
290
+ } ;
291
+
292
+ const serverAppSettingsTwo : FirebaseServerAppSettings = {
293
+ automaticDataCollectionEnabled : false
294
+ } ;
295
+
296
+ const appOne = initializeServerApp ( options , serverAppSettingsOne ) ;
297
+ expect ( appOne ) . to . not . equal ( null ) ;
298
+ expect ( appOne . automaticDataCollectionEnabled ) . to . be . false ;
299
+ const appTwo = initializeServerApp ( options , serverAppSettingsTwo ) ;
300
+ expect ( appTwo ) . to . not . equal ( null ) ;
301
+ expect ( appTwo ) . to . not . equal ( appOne ) ;
302
+ await deleteApp ( appOne ) ;
303
+ await deleteApp ( appTwo ) ;
304
+ } ) ;
305
+
306
+ it ( 'create duplicate FirebaseServerApps returns the same object' , async ( ) => {
307
+ if ( isBrowser ( ) ) {
308
+ // FirebaseServerApp isn't supported for execution in browser enviornments.
309
+ return ;
310
+ }
311
+
312
+ const options = { apiKey : 'APIKEY' } ;
313
+ const serverAppSettings : FirebaseServerAppSettings = {
314
+ automaticDataCollectionEnabled : false ,
315
+ releaseOnDeref : options
316
+ } ;
317
+
318
+ const appOne = initializeServerApp ( options , serverAppSettings ) ;
319
+ expect ( appOne ) . to . not . equal ( null ) ;
320
+ expect ( appOne . automaticDataCollectionEnabled ) . to . be . false ;
321
+ const appTwo = initializeServerApp ( options , serverAppSettings ) ;
322
+ expect ( appTwo ) . to . not . equal ( null ) ;
323
+ expect ( appTwo ) . to . equal ( appOne ) ;
324
+ await deleteApp ( appOne ) ;
325
+
326
+ // TODO: When Reference Counting works, update test. The following line should be false
327
+ // until and the app should be deleted a second time.
328
+ expect ( ( appOne as FirebaseServerAppImpl ) . isDeleted ) . to . be . true ;
329
+ // await deleteApp(appTwo);
330
+ } ) ;
331
+
275
332
describe ( 'getApp' , ( ) => {
276
333
it ( 'retrieves DEFAULT App' , ( ) => {
277
334
const app = initializeApp ( { } ) ;
0 commit comments