|
| 1 | +import { ReflectiveInjector, Provider } from '@angular/core'; |
| 2 | +import { TestBed, inject } from '@angular/core/testing'; |
| 3 | +import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseNameOrConfigToken } from 'angularfire2'; |
| 4 | +import { AngularFireFunctions, AngularFireFunctionsModule } from 'angularfire2/functions'; |
| 5 | +import { COMMON_CONFIG } from './test-config'; |
| 6 | + |
| 7 | +describe('AngularFireFunctions', () => { |
| 8 | + let app: FirebaseApp; |
| 9 | + let afFns: AngularFireFunctions; |
| 10 | + |
| 11 | + beforeEach(() => { |
| 12 | + TestBed.configureTestingModule({ |
| 13 | + imports: [ |
| 14 | + AngularFireModule.initializeApp(COMMON_CONFIG), |
| 15 | + AngularFireFunctionsModule |
| 16 | + ] |
| 17 | + }); |
| 18 | + inject([FirebaseApp, AngularFireFunctions], (app_: FirebaseApp, _fn: AngularFireFunctions) => { |
| 19 | + app = app_; |
| 20 | + afFns = _fn; |
| 21 | + })(); |
| 22 | + }); |
| 23 | + |
| 24 | + afterEach(done => { |
| 25 | + app.delete(); |
| 26 | + done(); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should be exist', () => { |
| 30 | + expect(afFns instanceof AngularFireFunctions).toBe(true); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should have the Firebase Functions instance', () => { |
| 34 | + expect(afFns.functions).toBeDefined(); |
| 35 | + }); |
| 36 | + |
| 37 | +}); |
| 38 | + |
| 39 | +const FIREBASE_APP_NAME_TOO = (Math.random() + 1).toString(36).substring(7); |
| 40 | + |
| 41 | +describe('AngularFireFunctions with different app', () => { |
| 42 | + let app: FirebaseApp; |
| 43 | + let afFns: AngularFireFunctions; |
| 44 | + |
| 45 | + beforeEach(() => { |
| 46 | + TestBed.configureTestingModule({ |
| 47 | + imports: [ |
| 48 | + AngularFireModule.initializeApp(COMMON_CONFIG), |
| 49 | + AngularFireFunctionsModule |
| 50 | + ], |
| 51 | + providers: [ |
| 52 | + { provide: FirebaseNameOrConfigToken, useValue: FIREBASE_APP_NAME_TOO }, |
| 53 | + { provide: FirebaseOptionsToken, useValue: COMMON_CONFIG } |
| 54 | + ] |
| 55 | + }); |
| 56 | + inject([FirebaseApp, AngularFireFunctions], (app_: FirebaseApp, _fns: AngularFireFunctions) => { |
| 57 | + app = app_; |
| 58 | + afFns = _fns; |
| 59 | + })(); |
| 60 | + }); |
| 61 | + |
| 62 | + afterEach(done => { |
| 63 | + app.delete(); |
| 64 | + done(); |
| 65 | + }); |
| 66 | + |
| 67 | + describe('<constructor>', () => { |
| 68 | + |
| 69 | + it('should be an AngularFireAuth type', () => { |
| 70 | + expect(afFns instanceof AngularFireFunctions).toEqual(true); |
| 71 | + }); |
| 72 | + |
| 73 | + }); |
| 74 | + |
| 75 | +}); |
0 commit comments