File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export async function activate(remoteConfig: RemoteConfig): Promise<boolean> {
76
76
/**
77
77
* Configures the Remote Config SDK to talk to a local emulator
78
78
* instead of product.
79
- *
79
+ *
80
80
* Must be called before performing any fetches against production
81
81
* Remote Config.
82
82
*
@@ -85,10 +85,10 @@ export async function activate(remoteConfig: RemoteConfig): Promise<boolean> {
85
85
*
86
86
* @public
87
87
*/
88
- export function connectRemoteConfigEmulator (
88
+ export function connectRemoteConfigEmulator (
89
89
remoteConfig : RemoteConfig ,
90
90
url : string
91
- ) {
91
+ ) : void {
92
92
const rc = getModularInstance ( remoteConfig ) as RemoteConfigImpl ;
93
93
94
94
// To avoid the footgun of fetching from prod first,
Original file line number Diff line number Diff line change @@ -518,4 +518,28 @@ describe('RemoteConfig', () => {
518
518
) ;
519
519
} ) ;
520
520
} ) ;
521
+
522
+ describe ( 'connectRemoteConfigEmulator' , ( ) => {
523
+ it ( 'changes the remote config API URL' , ( ) => {
524
+ const emulatorUrl = 'http://localhost:9200' ;
525
+
526
+ // init storage as if it had never fetched
527
+ storageCache . getLastFetchStatus = sinon . stub ( ) . returns ( undefined ) ;
528
+
529
+ api . connectRemoteConfigEmulator ( rc , emulatorUrl ) ;
530
+ expect ( window . FIREBASE_REMOTE_CONFIG_URL_BASE === emulatorUrl ) . to . be . true ;
531
+ } ) ;
532
+
533
+ it ( 'can not be called if a fetch has already happened' , ( ) => {
534
+ const emulatorUrl = 'http://localhost:9200' ;
535
+
536
+ // init storage as if it had never fetched
537
+ storageCache . getLastFetchStatus = sinon . stub ( ) . returns ( 'success' ) ;
538
+
539
+ const expectedError = ERROR_FACTORY . create ( ErrorCode . ALREADY_FETCHED ) ;
540
+ expect ( ( ) => api . connectRemoteConfigEmulator ( rc , emulatorUrl ) ) . to . throw (
541
+ expectedError . message
542
+ ) ;
543
+ } ) ;
544
+ } ) ;
521
545
} ) ;
You can’t perform that action at this time.
0 commit comments