mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-29 04:35:43 +08:00
@@ -1,6 +1,14 @@
|
||||
import functions from '../lib';
|
||||
import functions, { firebase } from '../lib';
|
||||
|
||||
describe('Cloud Functions', () => {
|
||||
describe('namespace', () => {
|
||||
it('accessible from firebase.app()', () => {
|
||||
const app = firebase.app();
|
||||
expect(app.functions).toBeDefined();
|
||||
expect(app.functions().httpsCallable).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('useFunctionsEmulator()', () => {
|
||||
it('useFunctionsEmulator -> uses 10.0.2.2', () => {
|
||||
functions().useFunctionsEmulator('http://localhost');
|
||||
@@ -9,4 +17,17 @@ describe('Cloud Functions', () => {
|
||||
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('httpcallable()', () => {
|
||||
it('throws an error with an incorrect timeout', () => {
|
||||
try {
|
||||
const app = firebase.app();
|
||||
app.functions().httpsCallable('example', { timeout: 'test' });
|
||||
return Promise.reject(new Error('Did not throw'));
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('HttpsCallableOptions.timeout expected a Number in milliseconds');
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,12 +19,6 @@ const { SAMPLE_DATA } = require('@react-native-firebase/private-tests-firebase-f
|
||||
|
||||
describe('functions()', () => {
|
||||
describe('namespace', () => {
|
||||
it('accessible from firebase.app()', () => {
|
||||
const app = firebase.app();
|
||||
should.exist(app.functions);
|
||||
app.functions().httpsCallable.should.be.a.Function();
|
||||
});
|
||||
|
||||
it('accepts passing in an FirebaseApp instance as first arg', async () => {
|
||||
const appName = `functionsApp${FirebaseHelpers.id}1`;
|
||||
const platformAppConfig = FirebaseHelpers.app.config();
|
||||
@@ -65,16 +59,6 @@ describe('functions()', () => {
|
||||
});
|
||||
});
|
||||
|
||||
android.it('useFunctionsEmulator -> uses 10.0.2.2', async () => {
|
||||
const region = 'europe-west2';
|
||||
const functions = firebase.app().functions(region);
|
||||
|
||||
functions.useFunctionsEmulator('http://localhost');
|
||||
functions._useFunctionsEmulatorOrigin.should.equal('http://10.0.2.2');
|
||||
functions.useFunctionsEmulator('http://127.0.0.1');
|
||||
functions._useFunctionsEmulatorOrigin.should.equal('http://10.0.2.2');
|
||||
});
|
||||
|
||||
it('useFunctionsEmulator', async () => {
|
||||
const region = 'europe-west2';
|
||||
const fnName = 'invertaseReactNativeFirebaseFunctionsEmulator';
|
||||
|
||||
Reference in New Issue
Block a user