|
1 | 1 | import {TestBed, ComponentFixture} from '@angular/core/testing';
|
2 |
| -import {Component, DebugElement, Type} from '@angular/core'; |
| 2 | +import {Component, DebugElement, Type, ViewChild} from '@angular/core'; |
3 | 3 | import {By} from '@angular/platform-browser';
|
4 | 4 | import {MatGridList, MatGridListModule} from './index';
|
5 | 5 | import {MatGridTile, MatGridTileText} from './grid-tile';
|
@@ -34,6 +34,20 @@ describe('MatGridList', () => {
|
34 | 34 | expect(() => fixture.detectChanges()).toThrowError(/tile with colspan 5 is wider than grid/);
|
35 | 35 | });
|
36 | 36 |
|
| 37 | + it('should set the columns to zero if a negative number is passed in', () => { |
| 38 | + const fixture = createComponent(GridListWithDynamicCols); |
| 39 | + fixture.detectChanges(); |
| 40 | + |
| 41 | + expect(fixture.componentInstance.gridList.cols).toBe(2); |
| 42 | + |
| 43 | + expect(() => { |
| 44 | + fixture.componentInstance.cols = -2; |
| 45 | + fixture.detectChanges(); |
| 46 | + }).not.toThrow(); |
| 47 | + |
| 48 | + expect(fixture.componentInstance.gridList.cols).toBe(1); |
| 49 | + }); |
| 50 | + |
37 | 51 | it('should default to 1:1 row height if undefined ', () => {
|
38 | 52 | const fixture = createComponent(GridListWithUnspecifiedRowHeight);
|
39 | 53 | fixture.detectChanges();
|
@@ -334,6 +348,12 @@ class GridListWithInvalidRowHeightRatio { }
|
334 | 348 | '<mat-grid-list cols="4"><mat-grid-tile colspan="5"></mat-grid-tile></mat-grid-list>'})
|
335 | 349 | class GridListWithTooWideColspan { }
|
336 | 350 |
|
| 351 | +@Component({template: '<mat-grid-list [cols]="cols"></mat-grid-list>'}) |
| 352 | +class GridListWithDynamicCols { |
| 353 | + @ViewChild(MatGridList) gridList: MatGridList; |
| 354 | + cols = 2; |
| 355 | +} |
| 356 | + |
337 | 357 | @Component({template: `
|
338 | 358 | <div style="width:200px">
|
339 | 359 | <mat-grid-list cols="1">
|
|
0 commit comments