Skip to content

Commit 849864f

Browse files
MichaelVerdonmikehardy
authored andcommitted
chore(app-distribution): deprecations for v8 API ahead of future major release
1 parent 497c6d1 commit 849864f

3 files changed

Lines changed: 89 additions & 6 deletions

File tree

packages/app-distribution/__tests__/app-distribution.test.ts

Lines changed: 76 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,22 @@ import {
99
signOutTester,
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+
20+
// Mock isIOS to be true so the app distribution methods work in tests
21+
jest.mock('@react-native-firebase/app/lib/common', () => {
22+
const actualCommon = jest.requireActual('@react-native-firebase/app/lib/common');
23+
return Object.assign({}, actualCommon, {
24+
isIOS: true,
25+
});
26+
});
27+
1228
describe('appDistribution()', function () {
1329
describe('namespace', function () {
1430
beforeAll(async function () {
@@ -49,4 +65,63 @@ describe('appDistribution()', function () {
4965
expect(signOutTester).toBeDefined();
5066
});
5167
});
68+
69+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
70+
let appDistributionV9Deprecation: CheckV9DeprecationFunction;
71+
72+
beforeEach(function () {
73+
appDistributionV9Deprecation = createCheckV9Deprecation(['appDistribution']);
74+
75+
// @ts-ignore test
76+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
77+
return new Proxy(
78+
{},
79+
{
80+
get: () =>
81+
jest.fn().mockResolvedValue({
82+
constants: {
83+
isTesterSignedIn: true,
84+
},
85+
} as never),
86+
},
87+
);
88+
});
89+
});
90+
91+
it('isTesterSignedIn', function () {
92+
const appDistribution = getAppDistribution();
93+
appDistributionV9Deprecation(
94+
() => isTesterSignedIn(appDistribution),
95+
() => appDistribution.isTesterSignedIn(),
96+
'isTesterSignedIn',
97+
);
98+
});
99+
100+
it('signInTester', function () {
101+
const appDistribution = getAppDistribution();
102+
appDistributionV9Deprecation(
103+
() => signInTester(appDistribution),
104+
() => appDistribution.signInTester(),
105+
'signInTester',
106+
);
107+
});
108+
109+
it('checkForUpdate', function () {
110+
const appDistribution = getAppDistribution();
111+
appDistributionV9Deprecation(
112+
() => checkForUpdate(appDistribution),
113+
() => appDistribution.checkForUpdate(),
114+
'checkForUpdate',
115+
);
116+
});
117+
118+
it('signOutTester', function () {
119+
const appDistribution = getAppDistribution();
120+
appDistributionV9Deprecation(
121+
() => signOutTester(appDistribution),
122+
() => appDistribution.signOutTester(),
123+
'signOutTester',
124+
);
125+
});
126+
});
52127
});

packages/app-distribution/lib/modular/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getApp } from '@react-native-firebase/app';
2-
2+
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
33
/**
44
* @typedef {import("..").FirebaseApp} FirebaseApp
55
* @typedef {import("..").FirebaseAppDistributionTypes.AppDistributionRelease} AppDistributionRelease
@@ -22,29 +22,29 @@ export function getAppDistribution(app) {
2222
* @returns {Promise<boolean>}
2323
*/
2424
export function isTesterSignedIn(appDistribution) {
25-
return appDistribution.isTesterSignedIn();
25+
return appDistribution.isTesterSignedIn.call(appDistribution, MODULAR_DEPRECATION_ARG);
2626
}
2727

2828
/**
2929
* @param {FirebaseAppDistribution} appDistribution
3030
* @returns {Promise<void>}
3131
*/
3232
export function signInTester(appDistribution) {
33-
return appDistribution.signInTester();
33+
return appDistribution.signInTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
3434
}
3535

3636
/**
3737
* @param {FirebaseAppDistribution} appDistribution
3838
* @returns {AppDistributionRelease>}
3939
*/
4040
export function checkForUpdate(appDistribution) {
41-
return appDistribution.checkForUpdate();
41+
return appDistribution.checkForUpdate.call(appDistribution, MODULAR_DEPRECATION_ARG);
4242
}
4343

4444
/**
4545
* @param {FirebaseAppDistribution} appDistribution
4646
* @returns {Promise<void>}
4747
*/
4848
export function signOutTester(appDistribution) {
49-
return appDistribution.signOutTester();
49+
return appDistribution.signOutTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
5050
}

packages/app/lib/common/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ const mapOfDeprecationReplacements = {
269269
nanoseconds: NO_REPLACEMENT,
270270
},
271271
},
272+
appDistribution: {
273+
default: {
274+
isTesterSignedIn: 'isTesterSignedIn()',
275+
signInTester: 'signInTester()',
276+
checkForUpdate: 'checkForUpdate()',
277+
signOutTester: 'signOutTester()',
278+
},
279+
},
272280
};
273281

274282
const modularDeprecationMessage =

0 commit comments

Comments
 (0)