@@ -28,6 +28,7 @@ describe('MatGridList', () => {
28
28
GridListWithComplexLayout ,
29
29
GridListWithFootersWithoutLines ,
30
30
GridListWithFooterContainingTwoLines ,
31
+ GridListWithoutMatchingGap ,
31
32
] ,
32
33
} ) ;
33
34
@@ -287,6 +288,15 @@ describe('MatGridList', () => {
287
288
expect ( getStyle ( tile , 'height' ) ) . toBe ( '400px' ) ;
288
289
} ) ;
289
290
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
+
290
300
} ) ;
291
301
292
302
@@ -298,7 +308,7 @@ function getStyle(el: DebugElement, prop: string): string {
298
308
function getComputedLeft ( element : DebugElement ) : number {
299
309
// While the other properties in this test use `getComputedStyle`, we use `getBoundingClientRect`
300
310
// 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
302
312
// browsers, by default, add a margin to the body (typically 8px).
303
313
let elementRect = element . nativeElement . getBoundingClientRect ( ) ;
304
314
let bodyRect = document . body . getBoundingClientRect ( ) ;
@@ -458,3 +468,13 @@ class GridListWithFootersWithoutLines { }
458
468
</mat-grid-tile>
459
469
</mat-grid-list>` } )
460
470
class 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