|
1 | 1 | import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
|
2 |
| -import {Component, ViewChild} from '@angular/core'; |
| 2 | +import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core'; |
3 | 3 | import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
|
4 | 4 | import {By} from '@angular/platform-browser';
|
5 | 5 | import {ViewportRuler} from '@angular/cdk/overlay';
|
@@ -169,6 +169,23 @@ describe('MdTabGroup', () => {
|
169 | 169 | expect(testElement.querySelectorAll('.mat-ripple-element').length)
|
170 | 170 | .toBe(0, 'Expected no ripple to show up on label mousedown.');
|
171 | 171 | });
|
| 172 | + |
| 173 | + it('should set the isActive flag on each of the tabs', () => { |
| 174 | + fixture.detectChanges(); |
| 175 | + |
| 176 | + const tabs = fixture.componentInstance.tabs.toArray(); |
| 177 | + |
| 178 | + expect(tabs[0].isActive).toBe(false); |
| 179 | + expect(tabs[1].isActive).toBe(true); |
| 180 | + expect(tabs[2].isActive).toBe(false); |
| 181 | + |
| 182 | + fixture.componentInstance.selectedIndex = 2; |
| 183 | + fixture.detectChanges(); |
| 184 | + |
| 185 | + expect(tabs[0].isActive).toBe(false); |
| 186 | + expect(tabs[1].isActive).toBe(false); |
| 187 | + expect(tabs[2].isActive).toBe(true); |
| 188 | + }); |
172 | 189 | });
|
173 | 190 |
|
174 | 191 | describe('dynamic binding tabs', () => {
|
@@ -364,6 +381,7 @@ describe('nested MdTabGroup with enabled animations', () => {
|
364 | 381 | `
|
365 | 382 | })
|
366 | 383 | class SimpleTabsTestApp {
|
| 384 | + @ViewChildren(MdTab) tabs: QueryList<MdTab>; |
367 | 385 | selectedIndex: number = 1;
|
368 | 386 | focusEvent: any;
|
369 | 387 | selectEvent: any;
|
|
0 commit comments