1- import { afterAll , beforeAll , describe , expect , it } from '@jest/globals' ;
1+ import { afterAll , beforeAll , beforeEach , describe , expect , it , jest } from '@jest/globals' ;
22
33import functions , {
44 firebase ,
@@ -9,6 +9,14 @@ import functions, {
99 HttpsErrorCode ,
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+
1220describe ( 'Cloud Functions' , function ( ) {
1321 describe ( 'namespace' , function ( ) {
1422 beforeAll ( async function ( ) {
@@ -85,4 +93,61 @@ describe('Cloud Functions', function () {
8593 expect ( HttpsErrorCode ) . toBeDefined ( ) ;
8694 } ) ;
8795 } ) ;
96+
97+ describe ( 'test `console.warn` is called for RNFB v8 API & not called for v9 API' , function ( ) {
98+ let functionsRefV9Deprecation : CheckV9DeprecationFunction ;
99+
100+ beforeEach ( function ( ) {
101+ functionsRefV9Deprecation = createCheckV9Deprecation ( [ 'functions' ] ) ;
102+
103+ // @ts -ignore test
104+ jest . spyOn ( FirebaseModule . prototype , 'native' , 'get' ) . mockImplementation ( ( ) => {
105+ return new Proxy (
106+ { } ,
107+ {
108+ get : ( ) =>
109+ jest . fn ( ) . mockResolvedValue ( {
110+ source : 'cache' ,
111+ changes : [ ] ,
112+ documents : [ ] ,
113+ metadata : { } ,
114+ path : 'foo' ,
115+ } as never ) ,
116+ } ,
117+ ) ;
118+ } ) ;
119+ } ) ;
120+
121+ describe ( 'Cloud Functions' , function ( ) {
122+ it ( 'useFunctionsEmulator()' , function ( ) {
123+ const app = firebase . app ( ) ;
124+ const functions = app . functions ( ) ;
125+ functionsRefV9Deprecation (
126+ ( ) => connectFunctionsEmulator ( functions , 'localhost' , 8080 ) ,
127+ ( ) => functions . useEmulator ( 'localhost' , 8080 ) ,
128+ 'useEmulator' ,
129+ ) ;
130+ } ) ;
131+
132+ it ( 'httpsCallable()' , function ( ) {
133+ const app = firebase . app ( ) ;
134+ const functions = app . functions ( ) ;
135+ functionsRefV9Deprecation (
136+ ( ) => httpsCallable ( functions , 'example' ) ,
137+ ( ) => functions . httpsCallable ( 'example' ) ,
138+ 'httpsCallable' ,
139+ ) ;
140+ } ) ;
141+
142+ it ( 'httpsCallableFromUrl()' , function ( ) {
143+ const app = firebase . app ( ) ;
144+ const functions = app . functions ( ) ;
145+ functionsRefV9Deprecation (
146+ ( ) => httpsCallableFromUrl ( functions , 'https://example.com/example' ) ,
147+ ( ) => functions . httpsCallableFromUrl ( 'https://example.com/example' ) ,
148+ 'httpsCallableFromUrl' ,
149+ ) ;
150+ } ) ;
151+ } ) ;
152+ } ) ;
88153} ) ;
0 commit comments