forked from angular/angularfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangularfire2.spec.ts
More file actions
83 lines (71 loc) · 2.28 KB
/
Copy pathangularfire2.spec.ts
File metadata and controls
83 lines (71 loc) · 2.28 KB
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
82
83
import * as firebase from 'firebase';
import {
TestBed,
inject
} from '@angular/core/testing';
import { ReflectiveInjector, Provider } from '@angular/core';
import {
AngularFire,
FirebaseObjectObservable,
FIREBASE_PROVIDERS,
AngularFireAuth,
FirebaseConfig,
FirebaseApp,
defaultFirebase,
AngularFireDatabase,
FirebaseAppConfig,
AngularFireModule
} from './angularfire2';
import { Subscription } from 'rxjs/Subscription';
import { COMMON_CONFIG, ANON_AUTH_CONFIG } from './test-config';
describe('angularfire', () => {
var subscription:Subscription;
var app: firebase.app.App;
var rootRef: firebase.database.Reference;
var questionsRef: firebase.database.Reference;
var listOfQuestionsRef: firebase.database.Reference;
var angularFire2: AngularFire;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AngularFireModule.initializeApp(COMMON_CONFIG, ANON_AUTH_CONFIG)]
});
inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
angularFire2 = _af;
app = firebaseApp;
rootRef = app.database().ref();
questionsRef = rootRef.child('questions');
listOfQuestionsRef = rootRef.child('list-of-questions');
})();
});
afterEach((done) => {
rootRef.remove()
if(subscription && !subscription.closed) {
subscription.unsubscribe();
}
app.delete().then(done, done.fail);
});
it('should be injectable via FIREBASE_PROVIDERS', () => {
expect(angularFire2 instanceof AngularFire).toBe(true);
});
describe('.auth', () => {
it('should be an instance of AuthService', inject([AngularFire], (af:AngularFire) => {
expect(af.auth instanceof AngularFireAuth).toBe(true);
}));
});
describe('.database', () => {
it('should be an instance of Database', inject([AngularFire], (af:AngularFire) => {
expect(af.database instanceof AngularFireDatabase).toBe(true);
}));
});
describe('FirebaseApp', () => {
it('should provide a FirebaseApp for the FirebaseApp binding', () => {
expect(typeof app.delete).toBe('function');
})
});
describe('defaultFirebase', () => {
it('should create an array of providers', () => {
const providers = defaultFirebase(COMMON_CONFIG);
expect(providers.length).toBe(2);
});
});
});