@@ -39,16 +39,31 @@ describe('MdTabGroup', () => {
39
39
checkSelectedIndex ( 0 ) ;
40
40
41
41
// 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 ] ;
43
43
tabLabel . nativeElement . click ( ) ;
44
44
checkSelectedIndex ( 1 ) ;
45
45
46
46
// 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 ] ;
48
48
tabLabel . nativeElement . click ( ) ;
49
49
checkSelectedIndex ( 2 ) ;
50
50
} ) ;
51
51
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
+
52
67
it ( 'should cycle through tab focus with focusNextTab/focusPreviousTab functions' ,
53
68
fakeAsync ( ( ) => {
54
69
let testComponent = fixture . componentInstance ;
@@ -170,7 +185,7 @@ describe('MdTabGroup', () => {
170
185
selector : 'test-app' ,
171
186
template : `
172
187
<md-tab-group class="tab-group"
173
- [selectedIndex]="selectedIndex"
188
+ [( selectedIndex) ]="selectedIndex"
174
189
(focusChange)="handleFocus($event)"
175
190
(selectChange)="handleSelection($event)">
176
191
<md-tab>
0 commit comments