Files
react-native-firebase/packages/functions/__tests__/functions.test.ts
Darren Ackers 0e72e62c8a tests(functions): jest migration (#3587)
* Updated functions jest tests

* Additonal tests added for httpcallable

* tests(functions): updated try catch tests

* Update .eslintrc.js

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
2020-05-05 23:28:36 +01:00

37 lines
1.1 KiB
TypeScript

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');
// @ts-ignore
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
functions().useFunctionsEmulator('http://127.0.0.1');
// @ts-ignore
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
});
});
describe('httpcallable()', () => {
it('throws an error with an incorrect timeout', () => {
const app = firebase.app();
// @ts-ignore
expect(() => app.functions().httpsCallable('example', { timeout: 'test' })).toThrow(
'HttpsCallableOptions.timeout expected a Number in milliseconds',
);
});
});
});