1- import { afterAll , beforeAll , describe , expect , it } from '@jest/globals' ;
1+ import { afterAll , beforeAll , describe , expect , it , beforeEach , jest } from '@jest/globals' ;
22
33import {
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+
1228describe ( '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} ) ;
0 commit comments