-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathfunctions.spec.ts
81 lines (66 loc) · 2.27 KB
/
functions.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { ReflectiveInjector, Provider } from '@angular/core';
import { TestBed, inject } from '@angular/core/testing';
import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseNameOrConfigToken } from '@angular/fire';
import { AngularFireFunctions, AngularFireFunctionsModule, FUNCTIONS_REGION, FUNCTIONS_ORIGIN } from '@angular/fire/functions';
import { COMMON_CONFIG } from './test-config';
describe('AngularFireFunctions', () => {
let app: FirebaseApp;
let afFns: AngularFireFunctions;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
AngularFireModule.initializeApp(COMMON_CONFIG),
AngularFireFunctionsModule
]
});
inject([FirebaseApp, AngularFireFunctions], (app_: FirebaseApp, _fn: AngularFireFunctions) => {
app = app_;
afFns = _fn;
})();
});
afterEach(done => {
app.delete();
done();
});
it('should be exist', () => {
expect(afFns instanceof AngularFireFunctions).toBe(true);
});
it('should have the Firebase Functions instance', () => {
expect(afFns.functions).toBeDefined();
});
});
const FIREBASE_APP_NAME_TOO = (Math.random() + 1).toString(36).substring(7);
describe('AngularFireFunctions with different app', () => {
let app: FirebaseApp;
let afFns: AngularFireFunctions;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
AngularFireModule.initializeApp(COMMON_CONFIG),
AngularFireFunctionsModule
],
providers: [
{ provide: FirebaseNameOrConfigToken, useValue: FIREBASE_APP_NAME_TOO },
{ provide: FirebaseOptionsToken, useValue: COMMON_CONFIG },
{ provide: FUNCTIONS_ORIGIN, useValue: 'http://0.0.0.0:9999' },
{ provide: FUNCTIONS_REGION, useValue: 'asia-northeast1' }
]
});
inject([FirebaseApp, AngularFireFunctions], (app_: FirebaseApp, _fns: AngularFireFunctions) => {
app = app_;
afFns = _fns;
})();
});
afterEach(done => {
app.delete();
done();
});
describe('<constructor>', () => {
it('should be an AngularFireAuth type', () => {
expect(afFns instanceof AngularFireFunctions).toEqual(true);
});
it('should have the Firebase Functions instance', () => {
expect(afFns.functions).toBeDefined();
});
});
});