@@ -10,6 +10,7 @@ import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing'
10
10
import { MD_TABS_DIRECTIVES , MdTabGroup } from './tabs' ;
11
11
import { Component } from '@angular/core' ;
12
12
import { By } from '@angular/platform-browser' ;
13
+ import { Observable } from 'rxjs/Observable' ;
13
14
14
15
describe ( 'MdTabGroup' , ( ) => {
15
16
let builder : TestComponentBuilder ;
@@ -86,6 +87,26 @@ describe('MdTabGroup', () => {
86
87
} ) ;
87
88
} ) ;
88
89
90
+ describe ( 'async tabs' , ( ) => {
91
+ beforeEach ( async ( ( ) => {
92
+ builder . createAsync ( AsyncTabsTestApp ) . then ( f => fixture = f ) ;
93
+ } ) ) ;
94
+
95
+ it ( 'should show tabs when they are available' , async ( ( ) => {
96
+ let labels = fixture . debugElement . queryAll ( By . css ( '.md-tab-label' ) ) ;
97
+
98
+ expect ( labels . length ) . toBe ( 0 ) ;
99
+
100
+ fixture . detectChanges ( ) ;
101
+
102
+ fixture . whenStable ( ) . then ( ( ) => {
103
+ fixture . detectChanges ( ) ;
104
+ labels = fixture . debugElement . queryAll ( By . css ( '.md-tab-label' ) ) ;
105
+ expect ( labels . length ) . toBe ( 2 ) ;
106
+ } ) ;
107
+ } ) ) ;
108
+ } ) ;
109
+
89
110
/**
90
111
* Checks that the `selectedIndex` has been updated; checks that the label and body have the
91
112
* `md-active` class
@@ -130,3 +151,30 @@ describe('MdTabGroup', () => {
130
151
class SimpleTabsTestApp {
131
152
selectedIndex : number = 1 ;
132
153
}
154
+
155
+ @Component ( {
156
+ selector : 'test-app' ,
157
+ template : `
158
+ <md-tab-group class="tab-group">
159
+ <md-tab *ngFor="let tab of tabs | async">
160
+ <template md-tab-label>{{ tab.label }}</template>
161
+ <template md-tab-content>{{ tab.content }}</template>
162
+ </md-tab>
163
+ </md-tab-group>
164
+ ` ,
165
+ directives : [ MD_TABS_DIRECTIVES ]
166
+ } )
167
+ class AsyncTabsTestApp {
168
+ private _tabs = [
169
+ { label : 'one' , content : 'one' } ,
170
+ { label : 'two' , content : 'two' }
171
+ ] ;
172
+
173
+ tabs : Observable < any > ;
174
+
175
+ constructor ( ) {
176
+ this . tabs = Observable . create ( ( observer : any ) => {
177
+ requestAnimationFrame ( ( ) => observer . next ( this . _tabs ) ) ;
178
+ } ) ;
179
+ }
180
+ }
0 commit comments