@@ -246,6 +246,65 @@ describe('MatGridList', () => {
246
246
expect ( getStyle ( tiles [ 3 ] , 'top' ) ) . toBe ( '101px' ) ;
247
247
} ) ;
248
248
249
+ it ( 'should lay out tiles correctly' , ( ) => {
250
+ const fixture = createComponent ( GridListWithLayout ) ;
251
+
252
+ fixture . detectChanges ( ) ;
253
+ const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
254
+
255
+ expect ( getStyle ( tiles [ 0 ] , 'width' ) ) . toBe ( '40px' ) ;
256
+ expect ( getStyle ( tiles [ 0 ] , 'height' ) ) . toBe ( '40px' ) ;
257
+ expect ( getComputedLeft ( tiles [ 0 ] ) ) . toBe ( 0 ) ;
258
+ expect ( getStyle ( tiles [ 0 ] , 'top' ) ) . toBe ( '0px' ) ;
259
+
260
+ expect ( getStyle ( tiles [ 1 ] , 'width' ) ) . toBe ( '20px' ) ;
261
+ expect ( getStyle ( tiles [ 1 ] , 'height' ) ) . toBe ( '20px' ) ;
262
+ expect ( getComputedLeft ( tiles [ 1 ] ) ) . toBe ( 40 ) ;
263
+ expect ( getStyle ( tiles [ 1 ] , 'top' ) ) . toBe ( '0px' ) ;
264
+
265
+ expect ( getStyle ( tiles [ 2 ] , 'width' ) ) . toBe ( '40px' ) ;
266
+ expect ( getStyle ( tiles [ 2 ] , 'height' ) ) . toBe ( '40px' ) ;
267
+ expect ( getComputedLeft ( tiles [ 2 ] ) ) . toBe ( 60 ) ;
268
+ expect ( getStyle ( tiles [ 2 ] , 'top' ) ) . toBe ( '0px' ) ;
269
+
270
+ expect ( getStyle ( tiles [ 3 ] , 'width' ) ) . toBe ( '40px' ) ;
271
+ expect ( getStyle ( tiles [ 3 ] , 'height' ) ) . toBe ( '40px' ) ;
272
+ expect ( getComputedLeft ( tiles [ 3 ] ) ) . toBe ( 0 ) ;
273
+ expect ( getStyle ( tiles [ 3 ] , 'top' ) ) . toBe ( '40px' ) ;
274
+
275
+ expect ( getStyle ( tiles [ 4 ] , 'width' ) ) . toBe ( '40px' ) ;
276
+ expect ( getStyle ( tiles [ 4 ] , 'height' ) ) . toBe ( '40px' ) ;
277
+ expect ( getComputedLeft ( tiles [ 4 ] ) ) . toBe ( 40 ) ;
278
+ expect ( getStyle ( tiles [ 4 ] , 'top' ) ) . toBe ( '40px' ) ;
279
+ } ) ;
280
+
281
+ it ( 'should lay out tiles correctly when single cell to be placed at the beginning' ,
282
+ ( ) => {
283
+ const fixture = createComponent ( GridListWithSingleCellAtBeginning ) ;
284
+
285
+ fixture . detectChanges ( ) ;
286
+ const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
287
+
288
+ expect ( getStyle ( tiles [ 0 ] , 'width' ) ) . toBe ( '40px' ) ;
289
+ expect ( getStyle ( tiles [ 0 ] , 'height' ) ) . toBe ( '40px' ) ;
290
+ expect ( getComputedLeft ( tiles [ 0 ] ) ) . toBe ( 0 ) ;
291
+ expect ( getStyle ( tiles [ 0 ] , 'top' ) ) . toBe ( '0px' ) ;
292
+
293
+ expect ( getStyle ( tiles [ 1 ] , 'width' ) ) . toBe ( '20px' ) ;
294
+ expect ( getStyle ( tiles [ 1 ] , 'height' ) ) . toBe ( '40px' ) ;
295
+ expect ( getComputedLeft ( tiles [ 1 ] ) ) . toBe ( 40 ) ;
296
+ expect ( getStyle ( tiles [ 1 ] , 'top' ) ) . toBe ( '0px' ) ;
297
+
298
+ expect ( getStyle ( tiles [ 2 ] , 'width' ) ) . toBe ( '40px' ) ;
299
+ expect ( getStyle ( tiles [ 2 ] , 'height' ) ) . toBe ( '40px' ) ;
300
+ expect ( getComputedLeft ( tiles [ 2 ] ) ) . toBe ( 60 ) ;
301
+ expect ( getStyle ( tiles [ 2 ] , 'top' ) ) . toBe ( '0px' ) ;
302
+
303
+ expect ( getStyle ( tiles [ 3 ] , 'height' ) ) . toBe ( '20px' ) ;
304
+ expect ( getComputedLeft ( tiles [ 3 ] ) ) . toBe ( 0 ) ;
305
+ expect ( getStyle ( tiles [ 3 ] , 'top' ) ) . toBe ( '40px' ) ;
306
+ } ) ;
307
+
249
308
it ( 'should add not add any classes to footers without lines' , ( ) => {
250
309
const fixture = createComponent ( GridListWithFootersWithoutLines ) ;
251
310
fixture . detectChanges ( ) ;
@@ -486,6 +545,29 @@ class GridListWithComplexLayout {
486
545
tiles : any [ ] ;
487
546
}
488
547
548
+ @Component ( { template : `
549
+ <div style="width:100px">
550
+ <mat-grid-list [cols]="10" gutterSize="0px" rowHeight="10px">
551
+ <mat-grid-tile [colspan]="4" [rowspan]="4"></mat-grid-tile>
552
+ <mat-grid-tile [colspan]="2" [rowspan]="2"></mat-grid-tile>
553
+ <mat-grid-tile [colspan]="4" [rowspan]="4"></mat-grid-tile>
554
+ <mat-grid-tile [colspan]="4" [rowspan]="4"></mat-grid-tile>
555
+ <mat-grid-tile [colspan]="4" [rowspan]="4"></mat-grid-tile>
556
+ </mat-grid-list>
557
+ </div>` } )
558
+ class GridListWithLayout { }
559
+
560
+ @Component ( { template : `
561
+ <div style="width:100px">
562
+ <mat-grid-list [cols]="10" gutterSize="0px" rowHeight="10px">
563
+ <mat-grid-tile [colspan]="4" [rowspan]="4"></mat-grid-tile>
564
+ <mat-grid-tile [colspan]="2" [rowspan]="4"></mat-grid-tile>
565
+ <mat-grid-tile [colspan]="4" [rowspan]="4"></mat-grid-tile>
566
+ <mat-grid-tile [colspan]="1" [rowspan]="2"></mat-grid-tile>
567
+ </mat-grid-list>
568
+ </div>` } )
569
+ class GridListWithSingleCellAtBeginning { }
570
+
489
571
@Component ( { template : `
490
572
<mat-grid-list cols="1">
491
573
<mat-grid-tile>
0 commit comments