Skip to content

Commit 94ae974

Browse files
committed
chore(app-distribution): deprecations for v8 API ahead of future major release
1 parent d0fa581 commit 94ae974

3 files changed

Lines changed: 92 additions & 5 deletions

File tree

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

Lines changed: 79 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,25 @@ 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(
22+
'@react-native-firebase/app/lib/common',
23+
() => ({
24+
isIOS: true,
25+
isAndroid: false,
26+
isOther: false,
27+
}),
28+
{ virtual: true },
29+
);
30+
1231
describe('appDistribution()', function () {
1332
describe('namespace', function () {
1433
beforeAll(async function () {
@@ -49,4 +68,63 @@ describe('appDistribution()', function () {
4968
expect(signOutTester).toBeDefined();
5069
});
5170
});
71+
72+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
73+
let appDistributionV9Deprecation: CheckV9DeprecationFunction;
74+
75+
beforeEach(function () {
76+
appDistributionV9Deprecation = createCheckV9Deprecation(['appDistribution']);
77+
78+
// @ts-ignore test
79+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
80+
return new Proxy(
81+
{},
82+
{
83+
get: () =>
84+
jest.fn().mockResolvedValue({
85+
constants: {
86+
isTesterSignedIn: true,
87+
},
88+
} as never),
89+
},
90+
);
91+
});
92+
});
93+
94+
it('isTesterSignedIn', function () {
95+
const appDistribution = getAppDistribution();
96+
appDistributionV9Deprecation(
97+
() => isTesterSignedIn(appDistribution),
98+
() => appDistribution.isTesterSignedIn(),
99+
'isTesterSignedIn',
100+
);
101+
});
102+
103+
it('signInTester', function () {
104+
const appDistribution = getAppDistribution();
105+
appDistributionV9Deprecation(
106+
() => signInTester(appDistribution),
107+
() => appDistribution.signInTester(),
108+
'signInTester',
109+
);
110+
});
111+
112+
it('checkForUpdate', function () {
113+
const appDistribution = getAppDistribution();
114+
appDistributionV9Deprecation(
115+
() => checkForUpdate(appDistribution),
116+
() => appDistribution.checkForUpdate(),
117+
'checkForUpdate',
118+
);
119+
});
120+
121+
it('signOutTester', function () {
122+
const appDistribution = getAppDistribution();
123+
appDistributionV9Deprecation(
124+
() => signOutTester(appDistribution),
125+
() => appDistribution.signOutTester(),
126+
'signOutTester',
127+
);
128+
});
129+
});
52130
});

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getApp } from '@react-native-firebase/app';
2+
import { MODULAR_DEPRECATION_ARG } from '../../../app/lib/common';
23

34
/**
45
* @typedef {import("..").FirebaseApp} FirebaseApp
@@ -22,29 +23,29 @@ export function getAppDistribution(app) {
2223
* @returns {Promise<boolean>}
2324
*/
2425
export function isTesterSignedIn(appDistribution) {
25-
return appDistribution.isTesterSignedIn();
26+
return appDistribution.isTesterSignedIn.call(appDistribution, MODULAR_DEPRECATION_ARG);
2627
}
2728

2829
/**
2930
* @param {FirebaseAppDistribution} appDistribution
3031
* @returns {Promise<void>}
3132
*/
3233
export function signInTester(appDistribution) {
33-
return appDistribution.signInTester();
34+
return appDistribution.signInTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
3435
}
3536

3637
/**
3738
* @param {FirebaseAppDistribution} appDistribution
3839
* @returns {AppDistributionRelease>}
3940
*/
4041
export function checkForUpdate(appDistribution) {
41-
return appDistribution.checkForUpdate();
42+
return appDistribution.checkForUpdate.call(appDistribution, MODULAR_DEPRECATION_ARG);
4243
}
4344

4445
/**
4546
* @param {FirebaseAppDistribution} appDistribution
4647
* @returns {Promise<void>}
4748
*/
4849
export function signOutTester(appDistribution) {
49-
return appDistribution.signOutTester();
50+
return appDistribution.signOutTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
5051
}

packages/app/lib/common/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ const mapOfDeprecationReplacements = {
211211
nanoseconds: NO_REPLACEMENT,
212212
},
213213
},
214+
appDistribution: {
215+
default: {
216+
isTesterSignedIn: 'isTesterSignedIn()',
217+
signInTester: 'signInTester()',
218+
checkForUpdate: 'checkForUpdate()',
219+
signOutTester: 'signOutTester()',
220+
},
221+
},
214222
};
215223

216224
const modularDeprecationMessage =

0 commit comments

Comments
 (0)