Skip to content

Commit 3ae9fad

Browse files
committed
test(messaging): complete modular port of e2e test suite
there are no valid deprecation warnings in messaging module e2e suite now
1 parent d29dfc8 commit 3ae9fad

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

packages/messaging/e2e/messaging.e2e.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ async function isAPNSCapableSimulator() {
4040
describe('messaging()', function () {
4141
before(async function () {
4242
// our device registration tests require permissions. Set them up
43-
await firebase.messaging().requestPermission({
43+
const { getMessaging, requestPermission } = messagingModular;
44+
await requestPermission(getMessaging(), {
4445
alert: true,
4546
badge: true,
4647
sound: true,
@@ -49,6 +50,16 @@ describe('messaging()', function () {
4950
});
5051

5152
describe('firebase v8 compatibility', function () {
53+
beforeEach(async function beforeEachTest() {
54+
// @ts-ignore
55+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
56+
});
57+
58+
afterEach(async function afterEachTest() {
59+
// @ts-ignore
60+
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false;
61+
});
62+
5263
describe('namespace', function () {
5364
it('accessible from firebase.app()', function () {
5465
const app = firebase.app();
@@ -479,9 +490,10 @@ describe('messaging()', function () {
479490
describe('firebase v9 modular API', function () {
480491
describe('getMessaging', function () {
481492
it('pass app as argument', function () {
493+
const { getApp } = modular;
482494
const { getMessaging } = messagingModular;
483495

484-
const messaging = getMessaging(firebase.app());
496+
const messaging = getMessaging(getApp());
485497

486498
messaging.constructor.name.should.be.equal('FirebaseMessagingModule');
487499
});
@@ -518,12 +530,12 @@ describe('messaging()', function () {
518530
it('sets the value', async function () {
519531
const { getMessaging, isAutoInitEnabled, setAutoInitEnabled } = messagingModular;
520532
should.equal(isAutoInitEnabled(getMessaging()), false);
521-
await firebase.messaging().setAutoInitEnabled(true);
533+
await setAutoInitEnabled(getMessaging(), true);
522534
should.equal(isAutoInitEnabled(getMessaging()), true);
523535

524536
// Set it back to the default value for future runs in re-use mode
525537
await setAutoInitEnabled(getMessaging(), false);
526-
should.equal(firebase.messaging().isAutoInitEnabled, false);
538+
should.equal(isAutoInitEnabled(getMessaging()), false);
527539
});
528540
});
529541

@@ -722,15 +734,16 @@ describe('messaging()', function () {
722734
});
723735

724736
it('should throw Error with wrong parameter types', async function () {
737+
const { getMessaging, getToken, deleteToken } = messagingModular;
725738
try {
726-
await firebase.messaging().deleteToken({ appName: 33 });
739+
await deleteToken(getMessaging(), { appName: 33 });
727740
return Promise.reject(new Error('Did not throw Error.'));
728741
} catch (e) {
729742
e.message.should.containEql("'appName' expected a string");
730743
}
731744

732745
try {
733-
await firebase.messaging().getToken({ senderId: 33 });
746+
await getToken(getMessaging(), { senderId: 33 });
734747
return Promise.reject(new Error('Did not throw Error.'));
735748
} catch (e) {
736749
e.message.should.containEql("'senderId' expected a string.");

packages/messaging/e2e/remoteMessage.e2e.js

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

1818
describe('remoteMessage modular', function () {
1919
describe('firebase 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('messaging().sendMessage(*)', function () {
2131
it('throws if used on ios', function () {
2232
if (Platform.ios) {

0 commit comments

Comments
 (0)