Skip to content

Commit 98d748b

Browse files
committed
test(database): fix all database e2e modular deprecation warnings
1 parent 0d2f2f4 commit 98d748b

39 files changed

+394
-21
lines changed

packages/database/e2e/DatabaseStatics.e2e.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ const TEST_PATH = `${PATH}/statics`;
2121

2222
describe('database.X', function () {
2323
describe('v8 compatibility', function () {
24+
beforeEach(async function beforeEachTest() {
25+
// @ts-ignore
26+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
27+
});
28+
29+
afterEach(async function afterEachTest() {
30+
// @ts-ignore
31+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
32+
});
33+
2434
after(function () {
2535
return wipe(TEST_PATH);
2636
});

packages/database/e2e/database.e2e.js

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

1818
describe('database()', function () {
1919
describe('v8 compatibility', 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
describe('namespace', function () {
2131
it('accessible from firebase.app()', function () {
2232
const app = firebase.app();
@@ -204,24 +214,22 @@ describe('database()', function () {
204214
describe('modular', function () {
205215
describe('namespace', function () {
206216
it('accessible from getDatabase', function () {
217+
const { getApp } = modular;
207218
const { getDatabase } = databaseModular;
208219

209-
const app = firebase.app();
210-
const database = getDatabase(app);
211-
should.exist(app.database);
212-
database.app.should.eql(app);
220+
const database = getDatabase(getApp());
221+
database.app.should.eql(getApp());
213222
});
214223

215224
it('supports multiple apps', async function () {
225+
const { getApp } = modular;
216226
const { getDatabase } = databaseModular;
217227
const database = getDatabase();
218-
const secondaryDatabase = getDatabase(firebase.app('secondaryFromNative'));
228+
const secondaryDatabase = getDatabase(getApp('secondaryFromNative'));
219229

220230
database.app.name.should.eql('[DEFAULT]');
221231

222232
secondaryDatabase.app.name.should.eql('secondaryFromNative');
223-
224-
firebase.app('secondaryFromNative').database().app.name.should.eql('secondaryFromNative');
225233
});
226234
});
227235

packages/database/e2e/helpers.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ const CONTENT = {
5252
};
5353

5454
exports.seed = function seed(path) {
55+
const { getDatabase, ref } = databaseModular;
5556
return Promise.all([
56-
firebase.database().ref(`${path}/types`).set(CONTENT.TYPES),
57-
firebase.database().ref(`${path}/query`).set(CONTENT.QUERY),
57+
ref(getDatabase(), `${path}/types`).set(CONTENT.TYPES),
58+
ref(getDatabase(), `${path}/query`).set(CONTENT.QUERY),
5859
// The database emulator does not load rules correctly. We force them pre-test.
5960
// TODO(ehesp): This is current erroring - however without it, we can't test rules.
6061
testingUtils.initializeTestEnvironment({
@@ -70,7 +71,8 @@ exports.seed = function seed(path) {
7071
};
7172

7273
exports.wipe = function wipe(path) {
73-
return firebase.database().ref(path).remove();
74+
const { getDatabase, ref } = databaseModular;
75+
return ref(getDatabase(), path).remove();
7476
};
7577

7678
exports.PATH = PATH;

packages/database/e2e/internal/connected.e2e.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ const { PATH } = require('../helpers');
1919
const TEST_PATH = `${PATH}/connected`;
2020

2121
describe("database().ref('.info/connected')", function () {
22-
before(async function () {
23-
await firebase.database().goOnline();
24-
});
25-
2622
describe('v8 compatibility', function () {
27-
after(async function () {
23+
beforeEach(async function beforeEachTest() {
24+
// @ts-ignore
25+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
26+
await firebase.database().goOnline();
27+
});
28+
29+
afterEach(async function afterEachTest() {
30+
// Ensures the db is online before running each test
2831
await firebase.database().goOnline();
32+
33+
// @ts-ignore
34+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
2935
});
3036

3137
xit('returns true when used with once', async function () {
@@ -61,6 +67,12 @@ describe("database().ref('.info/connected')", function () {
6167
});
6268

6369
describe('modular', function () {
70+
before(async function () {
71+
const { getDatabase, goOnline } = databaseModular;
72+
73+
await goOnline(getDatabase());
74+
});
75+
6476
after(async function () {
6577
const { getDatabase, goOnline } = databaseModular;
6678

packages/database/e2e/internal/serverTimeOffset.e2e.js

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

1818
describe("database().ref('.info/serverTimeOffset')", function () {
1919
describe('v8 compatibility', 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('returns a valid number value', async function () {
2131
const snapshot = await firebase.database().ref('.info/serverTimeOffset').once('value');
2232

packages/database/e2e/issues.e2e.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ describe('database issues', function () {
2929
});
3030

3131
describe('v8 compatibility', function () {
32+
beforeEach(async function beforeEachTest() {
33+
// @ts-ignore
34+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
35+
});
36+
37+
afterEach(async function afterEachTest() {
38+
// @ts-ignore
39+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
40+
});
41+
3242
// FIXME requires a second database set up locally, full app initialization etc
3343
xit('#2813 should return a null snapshot key if path is root', async function () {
3444
firebase.database('https://react-native-firebase-testing-db2.firebaseio.com');

packages/database/e2e/onDisconnect/cancel.e2e.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ describe('database().ref().onDisconnect().cancel()', function () {
2525
});
2626

2727
describe('v8 compatibility', function () {
28-
afterEach(async function () {
28+
beforeEach(async function beforeEachTest() {
29+
// @ts-ignore
30+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
31+
});
32+
33+
afterEach(async function afterEachTest() {
2934
// Ensures the db is online before running each test
3035
await firebase.database().goOnline();
36+
37+
// @ts-ignore
38+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
3139
});
3240

3341
it('throws if onComplete is not a function', function () {

packages/database/e2e/onDisconnect/remove.e2e.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ describe('database().ref().onDisconnect().remove()', function () {
2525
});
2626

2727
describe('v8 compatibility', function () {
28-
afterEach(async function () {
28+
beforeEach(async function beforeEachTest() {
29+
// @ts-ignore
30+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
31+
});
32+
33+
afterEach(async function afterEachTest() {
2934
// Ensures the db is online before running each test
3035
await firebase.database().goOnline();
36+
37+
// @ts-ignore
38+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
3139
});
3240

3341
it('throws if onComplete is not a function', function () {

packages/database/e2e/onDisconnect/set.e2e.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ describe('database().ref().onDisconnect().set()', function () {
2525
});
2626

2727
describe('v8 compatibility', function () {
28-
afterEach(async function () {
28+
beforeEach(async function beforeEachTest() {
29+
// @ts-ignore
30+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
31+
});
32+
33+
afterEach(async function afterEachTest() {
2934
// Ensures the db is online before running each test
3035
await firebase.database().goOnline();
36+
37+
// @ts-ignore
38+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
3139
});
3240

3341
it('throws if value is not a defined', function () {

packages/database/e2e/onDisconnect/setWithPriority.e2e.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ describe('database().ref().onDisconnect().setWithPriority()', function () {
2525
});
2626

2727
describe('v8 compatibility', function () {
28-
afterEach(async function () {
28+
beforeEach(async function beforeEachTest() {
29+
// @ts-ignore
30+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
31+
});
32+
33+
afterEach(async function afterEachTest() {
2934
// Ensures the db is online before running each test
3035
await firebase.database().goOnline();
36+
37+
// @ts-ignore
38+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
3139
});
3240

3341
it('throws if value is not a defined', function () {

0 commit comments

Comments
 (0)