|
1 | 1 | import {Component} from '@angular/core'; |
2 | 2 | import {TestBed, async, ComponentFixture, fakeAsync, flush} from '@angular/core/testing'; |
3 | 3 | import {By} from '@angular/platform-browser'; |
| 4 | +import {CommonModule} from '@angular/common'; |
4 | 5 | import {MatToolbarModule} from './index'; |
5 | 6 |
|
6 | 7 | describe('MatToolbar', () => { |
7 | 8 |
|
8 | 9 | beforeEach(async(() => { |
9 | 10 | TestBed.configureTestingModule({ |
10 | | - imports: [MatToolbarModule], |
11 | | - declarations: [ToolbarSingleRow, ToolbarMultipleRows, ToolbarMixedRowModes], |
| 11 | + imports: [MatToolbarModule, CommonModule], |
| 12 | + declarations: [ |
| 13 | + ToolbarSingleRow, |
| 14 | + ToolbarMultipleRows, |
| 15 | + ToolbarMixedRowModes, |
| 16 | + ToolbarMultipleIndirectRows, |
| 17 | + ], |
12 | 18 | }); |
13 | 19 |
|
14 | 20 | TestBed.compileComponents(); |
@@ -84,6 +90,15 @@ describe('MatToolbar', () => { |
84 | 90 | } |
85 | 91 | }).toThrowError(/attempting to combine different/i); |
86 | 92 | })); |
| 93 | + |
| 94 | + it('should pick up indirect descendant rows', () => { |
| 95 | + const fixture = TestBed.createComponent(ToolbarMultipleIndirectRows); |
| 96 | + fixture.detectChanges(); |
| 97 | + const toolbar = fixture.nativeElement.querySelector('.mat-toolbar'); |
| 98 | + |
| 99 | + expect(toolbar.classList).toContain('mat-toolbar-multiple-rows'); |
| 100 | + }); |
| 101 | + |
87 | 102 | }); |
88 | 103 |
|
89 | 104 | }); |
@@ -121,3 +136,17 @@ class ToolbarMultipleRows {} |
121 | 136 | class ToolbarMixedRowModes { |
122 | 137 | showToolbarRow: boolean = true; |
123 | 138 | } |
| 139 | + |
| 140 | + |
| 141 | +@Component({ |
| 142 | + // The ng-container is there so we have a node with a directive between the toolbar and the rows. |
| 143 | + template: ` |
| 144 | + <mat-toolbar> |
| 145 | + <ng-container [ngSwitch]="true"> |
| 146 | + <mat-toolbar-row>First Row</mat-toolbar-row> |
| 147 | + <mat-toolbar-row>Second Row</mat-toolbar-row> |
| 148 | + </ng-container> |
| 149 | + </mat-toolbar> |
| 150 | + ` |
| 151 | +}) |
| 152 | +class ToolbarMultipleIndirectRows {} |
0 commit comments