Skip to content

Commit 0e0b725

Browse files
MichaelVerdonmikehardy
authored andcommitted
chore(installations): deprecations for v8 API ahead of future major release
1 parent 757fa95 commit 0e0b725

File tree

3 files changed

+78
-15
lines changed

3 files changed

+78
-15
lines changed

packages/app/lib/common/index.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ const mapOfDeprecationReplacements = {
345345
nanoseconds: NO_REPLACEMENT,
346346
},
347347
},
348+
functions: {
349+
default: {
350+
useEmulator: 'connectFirestoreEmulator()',
351+
httpsCallable: 'httpsCallable()',
352+
httpsCallableFromUrl: 'httpsCallableFromUrl()',
353+
},
354+
statics: {
355+
HttpsErrorCode: 'HttpsErrorCode',
356+
},
357+
},
358+
installations: {
359+
default: {
360+
delete: 'deleteInstallations()',
361+
getId: 'getId()',
362+
getToken: 'getToken()',
363+
},
364+
},
348365
messaging: {
349366
default: {
350367
isAutoInitEnabled: 'isAutoInitEnabled()',
@@ -437,16 +454,6 @@ const mapOfDeprecationReplacements = {
437454
TaskState: 'TaskState',
438455
},
439456
},
440-
functions: {
441-
default: {
442-
useEmulator: 'connectFirestoreEmulator()',
443-
httpsCallable: 'httpsCallable()',
444-
httpsCallableFromUrl: 'httpsCallableFromUrl()',
445-
},
446-
statics: {
447-
HttpsErrorCode: 'HttpsErrorCode',
448-
},
449-
},
450457
};
451458

452459
const modularDeprecationMessage =

packages/installations/__tests__/installations.test.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
1+
import { afterAll, beforeAll, describe, expect, it, beforeEach, jest } from '@jest/globals';
22

33
import {
44
firebase,
@@ -9,6 +9,14 @@ import {
99
onIdChange,
1010
} from '../lib';
1111

12+
import {
13+
createCheckV9Deprecation,
14+
CheckV9DeprecationFunction,
15+
} from '../../app/lib/common/unitTestUtils';
16+
17+
// @ts-ignore test
18+
import FirebaseModule from '../../app/lib/internal/FirebaseModule';
19+
1220
describe('installations()', function () {
1321
describe('namespace', function () {
1422
beforeAll(async function () {
@@ -76,4 +84,52 @@ describe('installations()', function () {
7684
});
7785
});
7886
});
87+
88+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
89+
let installationsV9Deprecation: CheckV9DeprecationFunction;
90+
91+
beforeEach(function () {
92+
installationsV9Deprecation = createCheckV9Deprecation(['installations']);
93+
94+
// @ts-ignore test
95+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
96+
return new Proxy(
97+
{},
98+
{
99+
get: () =>
100+
jest.fn().mockResolvedValue({
101+
constants: {},
102+
} as never),
103+
},
104+
);
105+
});
106+
});
107+
108+
it('delete', function () {
109+
const installations = getInstallations();
110+
installationsV9Deprecation(
111+
() => deleteInstallations(installations),
112+
() => installations.delete(),
113+
'delete',
114+
);
115+
});
116+
117+
it('getId', function () {
118+
const installations = getInstallations();
119+
installationsV9Deprecation(
120+
() => getId(installations),
121+
() => installations.getId(),
122+
'getId',
123+
);
124+
});
125+
126+
it('getToken', function () {
127+
const installations = getInstallations();
128+
installationsV9Deprecation(
129+
() => getToken(installations),
130+
() => installations.getToken(),
131+
'getToken',
132+
);
133+
});
134+
});
79135
});

packages/installations/lib/modular/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { getApp } from '@react-native-firebase/app';
19-
19+
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
2020
/**
2121
* @typedef {import('..').FirebaseInstallationsTypes.Module} FirebaseInstallation
2222
*/
@@ -33,15 +33,15 @@ export function getInstallations(app) {
3333
* @returns {Promise<void>}
3434
*/
3535
export function deleteInstallations(installations) {
36-
return installations.delete();
36+
return installations.delete.call(installations, MODULAR_DEPRECATION_ARG);
3737
}
3838

3939
/**
4040
* @param {FirebaseInstallation} installations
4141
* @returns {Promise<string>}
4242
*/
4343
export function getId(installations) {
44-
return installations.getId();
44+
return installations.getId.call(installations, MODULAR_DEPRECATION_ARG);
4545
}
4646

4747
/**
@@ -50,7 +50,7 @@ export function getId(installations) {
5050
* @returns {Promise<string>}
5151
*/
5252
export function getToken(installations, forceRefresh) {
53-
return installations.getToken(forceRefresh);
53+
return installations.getToken.call(installations, forceRefresh, MODULAR_DEPRECATION_ARG);
5454
}
5555

5656
/**

0 commit comments

Comments
 (0)