MCPcopy Create free account
hub / github.com/angular/components / checkSelectedIndex

Function checkSelectedIndex

src/material/tabs/tab-group.spec.ts:1036–1053  ·  view source on GitHub ↗

* Checks that the `selectedIndex` has been updated; checks that the label and body have their * respective `active` classes

(expectedIndex: number, fixture: ComponentFixture<any>)

Source from the content-addressed store, hash-verified

1034 * respective `active` classes
1035 */
1036 function checkSelectedIndex(expectedIndex: number, fixture: ComponentFixture<any>) {
1037 fixture.detectChanges();
1038
1039 let tabComponent: MatTabGroup = fixture.debugElement.query(
1040 By.css('mat-tab-group'),
1041 ).componentInstance;
1042 expect(tabComponent.selectedIndex).toBe(expectedIndex);
1043
1044 let tabLabelElement = fixture.debugElement.query(
1045 By.css(`.mat-mdc-tab:nth-of-type(${expectedIndex + 1})`),
1046 ).nativeElement;
1047 expect(tabLabelElement.classList.contains('mdc-tab--active')).toBe(true);
1048
1049 let tabContentElement = fixture.debugElement.query(
1050 By.css(`mat-tab-body:nth-of-type(${expectedIndex + 1})`),
1051 ).nativeElement;
1052 expect(tabContentElement.classList.contains('mat-mdc-tab-body-active')).toBe(true);
1053 }
1054
1055 function getSelectedLabel(fixture: ComponentFixture<any>): HTMLElement {
1056 return fixture.nativeElement.querySelector('.mdc-tab--active');

Callers 1

tab-group.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected