Skip to content

Commit e16594b

Browse files
MichaelVerdonmikehardy
authored andcommitted
chore(installations): deprecations for v8 API ahead of future major release
1 parent 497c6d1 commit e16594b

3 files changed

Lines changed: 68 additions & 5 deletions

File tree

packages/app/lib/common/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ const mapOfDeprecationReplacements = {
269269
nanoseconds: NO_REPLACEMENT,
270270
},
271271
},
272+
installations: {
273+
default: {
274+
delete: 'deleteInstallations()',
275+
getId: 'getId()',
276+
getToken: 'getToken()',
277+
},
278+
},
272279
};
273280

274281
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)