1- import  { Component ,  Inject ,  OnInit ,  ViewChild ,  provide }  from  'angular2/core' ; 
1+ import  { Component ,  Inject ,  OnInit ,  ViewChild ,  enableProdMode ,  provide }  from  'angular2/core' ; 
2+ import  { AsyncPipe ,  NgFor }  from  'angular2/common' ; 
23
3- import  { fakeAsync ,  beforeEach ,  fit ,  inject ,  it ,  describe ,  expect ,  TestComponentBuilder }  from  'angular2/testing' ; 
4- import  { Observable }  from  'rxjs' ; 
5- import  { VirtualTimeScheduler }  from  'rxjs/scheduler/VirtualTimeScheduler' ; 
4+ import  { beforeEach ,  fit ,  inject ,  it ,  describe ,  expect ,  TestComponentBuilder }  from  'angular2/testing' ; 
65import  *  as  Firebase  from  'firebase' ; 
76
87import  { FirebaseList ,  FirebaseListFactory ,  onChildAdded ,  onChildMoved }  from  './firebase_list' ; 
9- import  { DEFAULT_FIREBASE }  from  '../angularfire' ; 
8+ import  { DEFAULT_FIREBASE ,  FirebaseObservable }  from  '../angularfire' ; 
9+ 
10+ enableProdMode ( ) ; 
1011
1112class  Todo  { 
1213  done :boolean ; 
1314} 
1415
15- const  rootFirebase  =  'ws://test.firebaseio.com' ; 
16+ const  rootFirebase  =  'ws://test.firebaseio.com:5000 ' ; 
1617
1718@Component ( { 
18-   template : '<h1>Hi</h1>' , 
19+   template : ` 
20+     <h1>Todos</h1> 
21+     <div *ngFor="#todo of todos | async" class="todo"> 
22+       {{todo.val().title}} 
23+     </div> 
24+     <h1>Posts</h1> 
25+     <div *ngFor="#post of posts | async" class="post"> 
26+       {{post.val().title}} 
27+     </div> 
28+   ` , 
1929  inputs :[ ] , 
30+   directives : [ NgFor ] , 
31+   pipes : [ AsyncPipe ] , 
2032  providers : [ 
2133    FirebaseList ( { 
2234      token : 'posts' , 
@@ -33,9 +45,8 @@ const rootFirebase = 'ws://test.firebaseio.com';
3345} ) 
3446class  MyComponent  { 
3547  constructor ( 
36-     @Inject ( 'posts' )  public  posts :Observable < any > , 
37-     @Inject ( Todo )  public  todos :Observable < Todo > )  { 
38-   } 
48+     @Inject ( 'posts' )  public  posts :FirebaseObservable < any > , 
49+     @Inject ( Todo )  public  todos :FirebaseObservable < Todo > )  { } 
3950} 
4051
4152
@@ -48,9 +59,22 @@ describe('FirebaseList', () => {
4859  it ( 'should assign an Observable to the designated parameters' ,  inject ( [ TestComponentBuilder ] ,  ( tcb :TestComponentBuilder )  =>  { 
4960    tcb . createAsync ( MyComponent ) 
5061      . then ( f  =>  { 
62+         var  ref  =  new  Firebase ( rootFirebase ) ; 
63+         ref . child ( 'todos' ) . push ( { 
64+           title : 'write post about angular 2' 
65+         } ) ; 
66+         ref . child ( 'posts' ) . push ( { 
67+           title : 'Angular 2 Beta' 
68+         } ) ; 
5169        f . detectChanges ( ) ; 
52-         expect ( f . componentInstance . posts  instanceof  Observable ) . toBe ( true ) ; 
53-         expect ( f . componentInstance . todos  instanceof  Observable ) . toBe ( true ) ; 
70+         expect ( f . componentInstance . posts  instanceof  FirebaseObservable ) . toBe ( true ) ; 
71+         expect ( f . componentInstance . todos  instanceof  FirebaseObservable ) . toBe ( true ) ; 
72+ 
73+         var  todoRows  =  f . nativeElement . querySelectorAll ( 'div.todo' ) ; 
74+         expect ( todoRows . length ) . toBe ( 1 ) ; 
75+ 
76+         var  postRows  =  f . nativeElement . querySelectorAll ( 'div.post' ) ; 
77+         expect ( postRows . length ) . toBe ( 1 ) ; 
5478      } ) ; 
5579  } ) ) ; 
5680
0 commit comments