1
- import { describe , it , beforeEach , expect , inject } from 'angular2/testing' ;
1
+ import {
2
+ describe ,
3
+ it ,
4
+ beforeEach ,
5
+ beforeEachProviders ,
6
+ expect ,
7
+ inject
8
+ } from 'angular2/testing' ;
2
9
import { Injector , provide , Provider } from 'angular2/core' ;
3
- import { FIREBASE_PROVIDERS , FirebaseUrl , FirebaseRef , defaultFirebase } from './angularfire' ;
10
+ import { AngularFire , FIREBASE_PROVIDERS , FirebaseUrl , FirebaseRef , defaultFirebase } from './angularfire' ;
4
11
5
- const testUrl = 'https ://ng2-forum-demo .firebaseio.com/' ;
12
+ const testUrl = 'http ://test .firebaseio.com:5000 /' ;
6
13
7
14
describe ( 'angularfire' , ( ) => {
15
+ it ( 'should be injectable via FIREBASE_PROVIDERS' , ( ) => {
16
+ var injector = Injector . resolveAndCreate ( [ FIREBASE_PROVIDERS , defaultFirebase ( testUrl ) ] ) ;
17
+ expect ( injector . get ( AngularFire ) ) . toBeAnInstanceOf ( AngularFire ) ;
18
+ } ) ;
19
+
20
+ describe ( '.list()' , ( ) => {
21
+ beforeEachProviders ( ( ) => [ FIREBASE_PROVIDERS , defaultFirebase ( testUrl ) ] ) ;
22
+
23
+ it ( 'should return an observable of the path' , inject ( [ AngularFire ] , ( af :AngularFire ) => {
24
+ var nextSpy = jasmine . createSpy ( 'next' ) ;
25
+ var questions = af . list ( 'list-of-questions' ) ;
26
+ questions . subscribe ( nextSpy ) ;
27
+ questions . add ( [ 'hello' ] ) ;
28
+ expect ( nextSpy . calls . first ( ) . args [ 0 ] [ 0 ] . val ( ) ) . toEqual ( [ 'hello' ] ) ;
29
+ } ) ) ;
30
+ } ) ;
31
+
32
+
8
33
describe ( 'FIREBASE_REF' , ( ) => {
9
34
it ( 'should provide a FirebaseRef for the FIREBASE_REF binding' , ( ) => {
10
35
var injector = Injector . resolveAndCreate ( [
@@ -16,17 +41,18 @@ describe('angularfire', () => {
16
41
expect ( typeof injector . get ( FirebaseRef ) . on ) . toBe ( 'function' ) ;
17
42
} )
18
43
} ) ;
19
-
44
+
20
45
describe ( 'defaultFirebase' , ( ) => {
21
46
it ( 'should create a provider' , ( ) => {
22
47
const provider = defaultFirebase ( testUrl ) ;
23
48
expect ( provider ) . toBeAnInstanceOf ( Provider ) ;
24
49
} ) ;
25
-
50
+
51
+
26
52
it ( 'should inject a FIR reference' , ( ) => {
27
53
const injector = Injector . resolveAndCreate ( [ defaultFirebase ( testUrl ) , FIREBASE_PROVIDERS ] ) ;
28
- expect ( injector . get ( FirebaseRef ) . toString ( ) ) . toBe ( testUrl ) ;
54
+ expect ( injector . get ( FirebaseRef ) . toString ( ) ) . toBe ( testUrl ) ;
29
55
} ) ;
30
56
} ) ;
31
-
57
+
32
58
} ) ;
0 commit comments