diff --git a/src/lib/grid-list/grid-list.spec.ts b/src/lib/grid-list/grid-list.spec.ts
index aced2497031b..c97182ea15e8 100644
--- a/src/lib/grid-list/grid-list.spec.ts
+++ b/src/lib/grid-list/grid-list.spec.ts
@@ -1,5 +1,5 @@
import {TestBed, ComponentFixture} from '@angular/core/testing';
-import {Component, DebugElement, Type} from '@angular/core';
+import {Component, DebugElement, Type, ViewChild} from '@angular/core';
import {By} from '@angular/platform-browser';
import {MatGridList, MatGridListModule} from './index';
import {MatGridTile, MatGridTileText} from './grid-tile';
@@ -34,6 +34,20 @@ describe('MatGridList', () => {
expect(() => fixture.detectChanges()).toThrowError(/tile with colspan 5 is wider than grid/);
});
+ it('should set the columns to zero if a negative number is passed in', () => {
+ const fixture = createComponent(GridListWithDynamicCols);
+ fixture.detectChanges();
+
+ expect(fixture.componentInstance.gridList.cols).toBe(2);
+
+ expect(() => {
+ fixture.componentInstance.cols = -2;
+ fixture.detectChanges();
+ }).not.toThrow();
+
+ expect(fixture.componentInstance.gridList.cols).toBe(1);
+ });
+
it('should default to 1:1 row height if undefined ', () => {
const fixture = createComponent(GridListWithUnspecifiedRowHeight);
fixture.detectChanges();
@@ -334,6 +348,12 @@ class GridListWithInvalidRowHeightRatio { }
'