|
2 | 2 | async, fakeAsync, tick, ComponentFixture, TestBed
|
3 | 3 | } from '@angular/core/testing';
|
4 | 4 | import {MdTabGroup, MdTabsModule, MdTabHeaderPosition} from './index';
|
5 |
| -import {Component, ViewChild} from '@angular/core'; |
| 5 | +import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core'; |
6 | 6 | import {NoopAnimationsModule, BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
7 | 7 | import {By} from '@angular/platform-browser';
|
8 | 8 | import {Observable} from 'rxjs/Observable';
|
@@ -173,6 +173,23 @@ describe('MdTabGroup', () => {
|
173 | 173 | expect(testElement.querySelectorAll('.mat-ripple-element').length)
|
174 | 174 | .toBe(0, 'Expected no ripple to show up on label mousedown.');
|
175 | 175 | });
|
| 176 | + |
| 177 | + it('should set the isActive flag on each of the tabs', () => { |
| 178 | + fixture.detectChanges(); |
| 179 | + |
| 180 | + const tabs = fixture.componentInstance.tabs.toArray(); |
| 181 | + |
| 182 | + expect(tabs[0].isActive).toBe(false); |
| 183 | + expect(tabs[1].isActive).toBe(true); |
| 184 | + expect(tabs[2].isActive).toBe(false); |
| 185 | + |
| 186 | + fixture.componentInstance.selectedIndex = 2; |
| 187 | + fixture.detectChanges(); |
| 188 | + |
| 189 | + expect(tabs[0].isActive).toBe(false); |
| 190 | + expect(tabs[1].isActive).toBe(false); |
| 191 | + expect(tabs[2].isActive).toBe(true); |
| 192 | + }); |
176 | 193 | });
|
177 | 194 |
|
178 | 195 | describe('dynamic binding tabs', () => {
|
@@ -368,6 +385,7 @@ describe('nested MdTabGroup with enabled animations', () => {
|
368 | 385 | `
|
369 | 386 | })
|
370 | 387 | class SimpleTabsTestApp {
|
| 388 | + @ViewChildren(MdTab) tabs: QueryList<MdTab>; |
371 | 389 | selectedIndex: number = 1;
|
372 | 390 | focusEvent: any;
|
373 | 391 | selectEvent: any;
|
|
0 commit comments