Skip to content

Commit 77bf463

Browse files
committed
fix tests
1 parent 3e314a7 commit 77bf463

File tree

6 files changed

+100
-61
lines changed

6 files changed

+100
-61
lines changed

config/webpack.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ module.exports = {
7575
}
7676
}
7777
},
78+
/**
79+
* Transform firebase packages to cjs, so they can be stubbed in tests
80+
*/
7881
{
7982
test: /\.js$/,
8083
include: function (modulePath) {
8184
const match = /node_modules\/@firebase.*/.test(modulePath);
82-
if (match) {
83-
console.log('modulePath', modulePath, match);
84-
}
8585
return match;
8686
},
8787
use: {

packages-exp/remote-config-exp/src/api.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,6 @@ export async function fetchConfig(remoteConfig: RemoteConfig): Promise<void> {
103103
}
104104
}
105105

106-
export async function fetchAndActivate(
107-
remoteConfig: RemoteConfig
108-
): Promise<boolean> {
109-
await fetchConfig(remoteConfig);
110-
return activate(remoteConfig);
111-
}
112-
113106
export function getAll(remoteConfig: RemoteConfig): Record<string, ValueType> {
114107
const rc = asRemoteConfigImpl(remoteConfig);
115108
return getAllKeys(
@@ -157,7 +150,7 @@ export function getValue(remoteConfig: RemoteConfig, key: string): ValueType {
157150
export function setLogLevel(
158151
remoteConfig: RemoteConfig,
159152
logLevel: RemoteConfigLogLevel
160-
) {
153+
): void {
161154
const rc = asRemoteConfigImpl(remoteConfig);
162155
switch (logLevel) {
163156
case 'debug':
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright 2020 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+
18+
import { RemoteConfig } from '@firebase/remote-config-types-exp';
19+
import { activate, fetchConfig } from './api';
20+
21+
// This API is put in a separate file, so we can stub fetchConfig and activate in tests.
22+
// It's not possible to stub standalone functions from the same module.
23+
export async function fetchAndActivate(
24+
remoteConfig: RemoteConfig
25+
): Promise<boolean> {
26+
await fetchConfig(remoteConfig);
27+
return activate(remoteConfig);
28+
}

packages-exp/remote-config-exp/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ declare global {
2828
}
2929

3030
export * from './api';
31+
export * from './api2';
3132

3233
/** register component and version */
3334
registerRemoteConfig();

packages-exp/remote-config-exp/src/remote_config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ export class RemoteConfig implements RemoteConfigType {
3939
* Tracks completion of initialization promise.
4040
* @internal
4141
*/
42-
public _isInitializationComplete = false;
42+
_isInitializationComplete = false;
4343

4444
/**
4545
* De-duplicates initialization calls.
4646
* @internal
4747
*/
48-
public _initializePromise?: Promise<void>;
48+
_initializePromise?: Promise<void>;
4949

5050
settings: Settings = {
5151
fetchTimeoutMillis: DEFAULT_FETCH_TIMEOUT_MILLIS,

0 commit comments

Comments
 (0)