@@ -28,6 +28,7 @@ describe('MatGridList', () => {
2828 GridListWithComplexLayout ,
2929 GridListWithFootersWithoutLines ,
3030 GridListWithFooterContainingTwoLines ,
31+ GridListWithoutMatchingGap ,
3132 ] ,
3233 } ) ;
3334
@@ -287,6 +288,15 @@ describe('MatGridList', () => {
287288 expect ( getStyle ( tile , 'height' ) ) . toBe ( '400px' ) ;
288289 } ) ;
289290
291+ it ( 'should ensure that all tiles are inside the grid when there are no matching gaps' , ( ) => {
292+ const fixture = TestBed . createComponent ( GridListWithoutMatchingGap ) ;
293+ const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
294+
295+ fixture . detectChanges ( ) ;
296+ expect ( tiles . every ( tile => getComputedLeft ( tile ) >= 0 ) )
297+ . toBe ( true , 'Expected none of the tiles to have a negative `left`' ) ;
298+ } ) ;
299+
290300} ) ;
291301
292302
@@ -298,7 +308,7 @@ function getStyle(el: DebugElement, prop: string): string {
298308function getComputedLeft ( element : DebugElement ) : number {
299309 // While the other properties in this test use `getComputedStyle`, we use `getBoundingClientRect`
300310 // for left because iOS Safari doesn't support using `getComputedStyle` to get the calculated
301- // `left` balue when using CSS `calc`. We subtract the `left` of the document body because
311+ // `left` value when using CSS `calc`. We subtract the `left` of the document body because
302312 // browsers, by default, add a margin to the body (typically 8px).
303313 let elementRect = element . nativeElement . getBoundingClientRect ( ) ;
304314 let bodyRect = document . body . getBoundingClientRect ( ) ;
@@ -458,3 +468,13 @@ class GridListWithFootersWithoutLines { }
458468 </mat-grid-tile>
459469 </mat-grid-list>` } )
460470class GridListWithFooterContainingTwoLines { }
471+
472+ @Component ( { template : `
473+ <mat-grid-list cols="5">
474+ <mat-grid-tile [rowspan]="1" [colspan]="3">1</mat-grid-tile>
475+ <mat-grid-tile [rowspan]="2" [colspan]="2">2</mat-grid-tile>
476+ <mat-grid-tile [rowspan]="1" [colspan]="2">3</mat-grid-tile>
477+ <mat-grid-tile [rowspan]="2" [colspan]="2">4</mat-grid-tile>
478+ </mat-grid-list>
479+ ` } )
480+ class GridListWithoutMatchingGap { }
0 commit comments