1+ /**
2+ * @license
3+ * Copyright 2025 Google LLC
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
17+
118import { expect } from 'chai' ;
2- import { ensureInitialized , fetchAndActivate , getRemoteConfig , getString } from '../src/index' ;
19+ import {
20+ ensureInitialized ,
21+ fetchAndActivate ,
22+ getRemoteConfig ,
23+ getString
24+ } from '../src/index' ;
325import '../test/setup' ;
4- import { deleteApp , FirebaseApp , initializeApp , _addOrOverwriteComponent } from '@firebase/app' ;
26+ import {
27+ deleteApp ,
28+ FirebaseApp ,
29+ initializeApp ,
30+ _addOrOverwriteComponent
31+ } from '@firebase/app' ;
532import * as sinon from 'sinon' ;
633import { FetchResponse } from '../src/client/remote_config_fetch_client' ;
7- import {
8- Component ,
9- ComponentType
10- } from '@firebase/component' ;
34+ import { Component , ComponentType } from '@firebase/component' ;
1135import { FirebaseInstallations } from '@firebase/installations-types' ;
12- import {
13- openDatabase ,
14- APP_NAMESPACE_STORE ,
15- } from '../src/storage/storage' ;
36+ import { openDatabase , APP_NAMESPACE_STORE } from '../src/storage/storage' ;
1637
1738const fakeFirebaseConfig = {
1839 apiKey : 'api-key' ,
@@ -36,7 +57,7 @@ describe('Remote Config API', () => {
3657 const STUB_FETCH_RESPONSE : FetchResponse = {
3758 status : 200 ,
3859 eTag : 'asdf' ,
39- config : { 'foobar' : 'hello world' } ,
60+ config : { 'foobar' : 'hello world' }
4061 } ;
4162 let fetchStub : sinon . SinonStub ;
4263
@@ -50,11 +71,11 @@ describe('Remote Config API', () => {
5071 ( ) => {
5172 return {
5273 getId : ( ) => Promise . resolve ( 'fis-id' ) ,
53- getToken : ( ) => Promise . resolve ( 'fis-token' ) ,
74+ getToken : ( ) => Promise . resolve ( 'fis-token' )
5475 } as any as FirebaseInstallations ;
5576 } ,
5677 ComponentType . PUBLIC
57- ) as any ,
78+ ) as any
5879 ) ;
5980 } ) ;
6081
@@ -65,16 +86,18 @@ describe('Remote Config API', () => {
6586 } ) ;
6687
6788 function setFetchResponse ( response : FetchResponse = { status : 200 } ) : void {
68- fetchStub . returns ( Promise . resolve ( {
69- ok : response . status === 200 ,
70- status : response . status ,
71- headers : new Headers ( { ETag : response . eTag || '' } ) ,
72- json : ( ) =>
73- Promise . resolve ( {
74- entries : response . config ,
75- state : 'OK'
76- } )
77- } as Response ) ) ;
89+ fetchStub . returns (
90+ Promise . resolve ( {
91+ ok : response . status === 200 ,
92+ status : response . status ,
93+ headers : new Headers ( { ETag : response . eTag || '' } ) ,
94+ json : ( ) =>
95+ Promise . resolve ( {
96+ entries : response . config ,
97+ state : 'OK'
98+ } )
99+ } as Response )
100+ ) ;
78101 }
79102
80103 it ( 'allows multiple initializations if options are same' , ( ) => {
@@ -115,11 +138,14 @@ describe('Remote Config API', () => {
115138 await fetchAndActivate ( rc ) ;
116139 expect ( fetchStub ) . to . be . calledOnceWith (
117140 'https://firebaseremoteconfig.googleapis.com/v1/projects/project-id/namespaces/altTemplate:fetch?key=api-key' ,
118- sinon . match . object ) ;
141+ sinon . match . object
142+ ) ;
119143 } ) ;
120144
121145 it ( 'hydrates with initialFetchResponse' , async ( ) => {
122- const rc = getRemoteConfig ( app , { initialFetchResponse : STUB_FETCH_RESPONSE } ) ;
146+ const rc = getRemoteConfig ( app , {
147+ initialFetchResponse : STUB_FETCH_RESPONSE
148+ } ) ;
123149 await ensureInitialized ( rc ) ;
124150 expect ( getString ( rc , 'foobar' ) ) . to . equal ( 'hello world' ) ;
125151 } ) ;
0 commit comments