Skip to content

Commit d86eeb7

Browse files
committed
throw in initializeServerApp if invoked in a browser env.
1 parent 7b02583 commit d86eeb7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/app/src/api.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { createTestComponent } from '../test/util';
4040
import { Component, ComponentType } from '@firebase/component';
4141
import { Logger } from '@firebase/logger';
4242
import { FirebaseAppImpl } from './firebaseApp';
43+
import { isBrowser } from '@firebase/util';
4344

4445
declare module '@firebase/component' {
4546
interface NameServiceMapping {
@@ -184,6 +185,23 @@ describe('API tests', () => {
184185

185186
describe('initializeServerApp', () => {
186187
it('creates FirebaseServerApp with options', () => {
188+
if (isBrowser()) {
189+
const options = {
190+
apiKey: 'APIKEY'
191+
};
192+
const serverAppSettings: FirebaseServerAppSettings = {};
193+
expect(() => initializeServerApp(options, serverAppSettings)).throws(
194+
/FirebaseServerApp is not for use in browser environments./
195+
);
196+
}
197+
});
198+
199+
it('creates FirebaseServerApp with options', () => {
200+
if (isBrowser()) {
201+
// FirebaseServerApp isn't supported for execution in browser enviornments.
202+
return;
203+
}
204+
187205
const options = {
188206
apiKey: 'APIKEY'
189207
};
@@ -196,6 +214,11 @@ describe('API tests', () => {
196214
});
197215

198216
it('creates FirebaseServerApp with automaticDataCollectionEnabled', () => {
217+
if (isBrowser()) {
218+
// FirebaseServerApp isn't supported for execution in browser enviornments.
219+
return;
220+
}
221+
199222
const options = {
200223
apiKey: 'APIKEY'
201224
};
@@ -210,6 +233,11 @@ describe('API tests', () => {
210233
});
211234

212235
it('creates FirebaseServerApp with releaseOnDeref', () => {
236+
if (isBrowser()) {
237+
// FirebaseServerApp isn't supported for execution in browser enviornments.
238+
return;
239+
}
240+
213241
const options = { apiKey: 'APIKEY' };
214242
const serverAppSettings: FirebaseServerAppSettings = {
215243
automaticDataCollectionEnabled: false,
@@ -222,6 +250,11 @@ describe('API tests', () => {
222250
});
223251

224252
it('creates FirebaseServerApp with FirebaseApp', () => {
253+
if (isBrowser()) {
254+
// FirebaseServerApp isn't supported for execution in browser enviornments.
255+
return;
256+
}
257+
225258
const options = {
226259
apiKey: 'test1'
227260
};

0 commit comments

Comments
 (0)