Skip to content

Commit da47720

Browse files
committed
test(app): fix all app e2e deprecation warnings
1 parent c4f5f0d commit da47720

File tree

3 files changed

+55
-31
lines changed

3 files changed

+55
-31
lines changed

packages/app/e2e/app.e2e.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717

1818
describe('modular', function () {
1919
describe('firebase v8 compat', function () {
20+
beforeEach(async function beforeEachTest() {
21+
// @ts-ignore
22+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
23+
});
24+
25+
afterEach(async function afterEachTest() {
26+
// @ts-ignore
27+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
28+
});
29+
2030
it('it should allow read the default app from native', function () {
2131
if (Platform.other) return; // Not supported on non-native platforms.
2232
// app is created in tests app before all hook
@@ -201,21 +211,20 @@ describe('modular', function () {
201211
});
202212

203213
it('it should initialize dynamic apps', async function () {
204-
const { initializeApp, getApps, getApp } = modular;
214+
const { initializeApp, getApps, getApp, deleteApp } = modular;
205215

206-
const appCount = firebase.apps.length;
216+
const appCount = getApps().length;
207217
const name = `testscoreapp${FirebaseHelpers.id}`;
208218
const platformAppConfig = FirebaseHelpers.app.config();
209219
const newApp = await initializeApp(platformAppConfig, name);
210220
newApp.name.should.equal(name);
211-
newApp.toString().should.equal(name);
212221
newApp.options.apiKey.should.equal(platformAppConfig.apiKey);
213222

214223
const apps = getApps();
215224

216225
should.equal(apps.includes(getApp(name)), true);
217226
should.equal(apps.length, appCount + 1);
218-
return newApp.delete();
227+
return deleteApp(newApp);
219228
});
220229

221230
it('should error if dynamic app initialization values are incorrect', async function () {
@@ -257,8 +266,8 @@ describe('modular', function () {
257266
} catch (e) {
258267
e.code.should.containEql('app/unknown');
259268
e.message.should.containEql('Configuration fails');
260-
should.equal(firebase.apps.length, appCount);
261-
should.equal(firebase.apps.includes('myname'), false);
269+
should.equal(getApps().length, appCount);
270+
should.equal(getApps().includes('myname'), false);
262271
}
263272
});
264273

@@ -270,7 +279,6 @@ describe('modular', function () {
270279
const newApp = await initializeApp(platformAppConfig, name);
271280

272281
newApp.name.should.equal(name);
273-
newApp.toString().should.equal(name);
274282
newApp.options.apiKey.should.equal(platformAppConfig.apiKey);
275283

276284
await deleteApp(newApp);

packages/app/e2e/asyncStorage.e2e.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ describe('firebase.setReactNativeAsyncStorage()', function () {
1616
});
1717

1818
it('throws if asyncStorage is not an object', function () {
19+
const { setReactNativeAsyncStorage } = modular;
1920
try {
20-
firebase.setReactNativeAsyncStorage(123);
21+
setReactNativeAsyncStorage(123);
2122
return Promise.reject(new Error('Did not throw an Error.'));
2223
} catch (error) {
2324
error.message.should.containEql("'asyncStorage' must be an object");
@@ -26,8 +27,9 @@ describe('firebase.setReactNativeAsyncStorage()', function () {
2627
});
2728

2829
it('throws if asyncStorage.setItem is not a function', function () {
30+
const { setReactNativeAsyncStorage } = modular;
2931
try {
30-
firebase.setReactNativeAsyncStorage({ setItem: 123 });
32+
setReactNativeAsyncStorage({ setItem: 123 });
3133
return Promise.reject(new Error('Did not throw an Error.'));
3234
} catch (error) {
3335
error.message.should.containEql("'asyncStorage.setItem' must be a function");
@@ -36,8 +38,9 @@ describe('firebase.setReactNativeAsyncStorage()', function () {
3638
});
3739

3840
it('throws if asyncStorage.getItem is not a function', function () {
41+
const { setReactNativeAsyncStorage } = modular;
3942
try {
40-
firebase.setReactNativeAsyncStorage({ setItem: sinon.spy(), getItem: 123 });
43+
setReactNativeAsyncStorage({ setItem: sinon.spy(), getItem: 123 });
4144
return Promise.reject(new Error('Did not throw an Error.'));
4245
} catch (error) {
4346
error.message.should.containEql("'asyncStorage.getItem' must be a function");
@@ -46,8 +49,9 @@ describe('firebase.setReactNativeAsyncStorage()', function () {
4649
});
4750

4851
it('throws if asyncStorage.removeItem is not a function', function () {
52+
const { setReactNativeAsyncStorage } = modular;
4953
try {
50-
firebase.setReactNativeAsyncStorage({
54+
setReactNativeAsyncStorage({
5155
setItem: sinon.spy(),
5256
getItem: sinon.spy(),
5357
removeItem: 123,
@@ -60,13 +64,14 @@ describe('firebase.setReactNativeAsyncStorage()', function () {
6064
});
6165

6266
it('sets the async storage instance', async function () {
67+
const { setReactNativeAsyncStorage } = modular;
6368
isMemoryStorage().should.equal(true);
6469

6570
const setItemSpy = sinon.spy();
6671
const getItemSpy = sinon.spy();
6772
const removeItemSpy = sinon.spy();
6873

69-
firebase.setReactNativeAsyncStorage({
74+
setReactNativeAsyncStorage({
7075
setItem: setItemSpy,
7176
getItem: getItemSpy,
7277
removeItem: removeItemSpy,
@@ -84,10 +89,11 @@ describe('firebase.setReactNativeAsyncStorage()', function () {
8489
});
8590

8691
it('works with @react-native-async-storage/async-storage', async function () {
92+
const { setReactNativeAsyncStorage } = modular;
8793
isMemoryStorage().should.equal(true);
8894
const key = Date.now().toString();
8995
const value = 'bar';
90-
firebase.setReactNativeAsyncStorage(asyncStorage);
96+
setReactNativeAsyncStorage(asyncStorage);
9197
isMemoryStorage().should.equal(false);
9298

9399
// Through our internals,

packages/app/e2e/utils.e2e.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,44 @@ describe('utils()', function () {
1919
if (Platform.other) return; // Not supported on non-native platforms.
2020

2121
describe('namespace', function () {
22+
beforeEach(async function beforeEachTest() {
23+
// @ts-ignore
24+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
25+
});
26+
27+
afterEach(async function afterEachTest() {
28+
// @ts-ignore
29+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
30+
});
31+
2232
it('accessible from firebase.app()', function () {
2333
const app = firebase.app();
2434
should.exist(app.utils);
2535
app.utils().app.should.equal(app);
2636
});
27-
});
2837

29-
describe('isRunningInTestLab', function () {
30-
it('returns true or false', function () {
31-
should.equal(firebase.utils().isRunningInTestLab, false);
38+
describe('isRunningInTestLab', function () {
39+
it('returns true or false', function () {
40+
should.equal(firebase.utils().isRunningInTestLab, false);
41+
});
3242
});
33-
});
3443

35-
describe('playServicesAvailability', function () {
36-
it('returns isAvailable and Play Service status', async function () {
37-
const playService = await firebase.utils().playServicesAvailability;
38-
//iOS always returns { isAvailable: true, status: 0}
39-
should(playService.isAvailable).equal(true);
40-
should(playService.status).equal(0);
44+
describe('playServicesAvailability', function () {
45+
it('returns isAvailable and Play Service status', async function () {
46+
const playService = await firebase.utils().playServicesAvailability;
47+
//iOS always returns { isAvailable: true, status: 0}
48+
should(playService.isAvailable).equal(true);
49+
should(playService.status).equal(0);
50+
});
4151
});
42-
});
4352

44-
describe('getPlayServicesStatus', function () {
45-
it('returns isAvailable and Play Service status', async function () {
46-
const status = await firebase.utils().getPlayServicesStatus();
47-
//iOS always returns { isAvailable: true, status: 0}
48-
should(status.isAvailable).equal(true);
49-
should(status.status).equal(0);
53+
describe('getPlayServicesStatus', function () {
54+
it('returns isAvailable and Play Service status', async function () {
55+
const status = await firebase.utils().getPlayServicesStatus();
56+
//iOS always returns { isAvailable: true, status: 0}
57+
should(status.isAvailable).equal(true);
58+
should(status.status).equal(0);
59+
});
5060
});
5161
});
5262
});

0 commit comments

Comments
 (0)