@@ -39,16 +39,31 @@ describe('MdTabGroup', () => {
3939 checkSelectedIndex ( 0 ) ;
4040
4141 // select the second tab
42- let tabLabel = fixture . debugElement . query ( By . css ( '.md-tab-label:nth-of-type(2) ' ) ) ;
42+ let tabLabel = fixture . debugElement . queryAll ( By . css ( '.md-tab-label' ) ) [ 1 ] ;
4343 tabLabel . nativeElement . click ( ) ;
4444 checkSelectedIndex ( 1 ) ;
4545
4646 // select the third tab
47- tabLabel = fixture . debugElement . query ( By . css ( '.md-tab-label:nth-of-type(3) ' ) ) ;
47+ tabLabel = fixture . debugElement . queryAll ( By . css ( '.md-tab-label' ) ) [ 2 ] ;
4848 tabLabel . nativeElement . click ( ) ;
4949 checkSelectedIndex ( 2 ) ;
5050 } ) ;
5151
52+ it ( 'should support two-way binding for selectedIndex' , async ( ( ) => {
53+ let component = fixture . componentInstance ;
54+ component . selectedIndex = 0 ;
55+
56+ fixture . detectChanges ( ) ;
57+
58+ let tabLabel = fixture . debugElement . queryAll ( By . css ( '.md-tab-label' ) ) [ 1 ] ;
59+ tabLabel . nativeElement . click ( ) ;
60+
61+ fixture . detectChanges ( ) ;
62+ fixture . whenStable ( ) . then ( ( ) => {
63+ expect ( component . selectedIndex ) . toBe ( 1 ) ;
64+ } ) ;
65+ } ) ) ;
66+
5267 it ( 'should cycle through tab focus with focusNextTab/focusPreviousTab functions' ,
5368 fakeAsync ( ( ) => {
5469 let testComponent = fixture . componentInstance ;
@@ -170,7 +185,7 @@ describe('MdTabGroup', () => {
170185 selector : 'test-app' ,
171186 template : `
172187 <md-tab-group class="tab-group"
173- [selectedIndex]="selectedIndex"
188+ [( selectedIndex) ]="selectedIndex"
174189 (focusChange)="handleFocus($event)"
175190 (selectChange)="handleSelection($event)">
176191 <md-tab>
0 commit comments