1- import { TestBed , ComponentFixture , inject } from '@angular/core/testing' ;
1+ import { TestBed , ComponentFixture } from '@angular/core/testing' ;
22import { Component , DebugElement , Type , ViewChild } from '@angular/core' ;
33import { By } from '@angular/platform-browser' ;
44import { MatGridList , MatGridListModule } from './index' ;
55import { MatGridTile , MatGridTileText } from './grid-tile' ;
66import { Directionality } from '@angular/cdk/bidi' ;
7- import { Platform } from '@angular/cdk/platform' ;
87
98describe ( 'MatGridList' , ( ) => {
10- let disableComputedStyleTests = false ;
11-
129 function createComponent < T > ( componentType : Type < T > ) : ComponentFixture < T > {
1310 TestBed . configureTestingModule ( {
1411 imports : [ MatGridListModule ] ,
1512 declarations : [ componentType ] ,
1613 } ) . compileComponents ( ) ;
1714
18- const fixture = TestBed . createComponent < T > ( componentType ) ;
19-
20- inject ( [ Platform ] , ( platform : Platform ) => {
21- // IE and Edge aren't consistent in the values that they return from `getComputedStyle`.
22- // In some cases they return the computed values, and in others the passed-in ones. We use
23- // this flag to disable the tests that depend on `getComputedStyle` in order to avoid flakes.
24- // TODO: we can re-enable them when we start testing against the Chromium-based Edge.
25- disableComputedStyleTests = platform . EDGE || platform . TRIDENT ;
26- } ) ( ) ;
27-
28- return fixture ;
15+ return TestBed . createComponent < T > ( componentType ) ;
2916 }
3017
31- afterEach ( ( ) => ( disableComputedStyleTests = false ) ) ;
32-
3318 it ( 'should throw error if cols is not defined' , ( ) => {
3419 const fixture = createComponent ( GridListWithoutCols ) ;
3520
@@ -86,10 +71,6 @@ describe('MatGridList', () => {
8671 it ( 'should default to 1:1 row height if undefined ' , ( ) => {
8772 const fixture = createComponent ( GridListWithUnspecifiedRowHeight ) ;
8873
89- if ( disableComputedStyleTests ) {
90- return ;
91- }
92-
9374 fixture . detectChanges ( ) ;
9475 const tile = fixture . debugElement . query ( By . directive ( MatGridTile ) ) ! ;
9576 const inlineStyles = tile . nativeElement . style ;
@@ -103,10 +84,6 @@ describe('MatGridList', () => {
10384 it ( 'should use a ratio row height if passed in' , ( ) => {
10485 const fixture = createComponent ( GirdListWithRowHeightRatio ) ;
10586
106- if ( disableComputedStyleTests ) {
107- return ;
108- }
109-
11087 fixture . componentInstance . rowHeight = '4:1' ;
11188 fixture . detectChanges ( ) ;
11289
@@ -128,10 +105,6 @@ describe('MatGridList', () => {
128105 it ( 'should divide row height evenly in "fit" mode' , ( ) => {
129106 const fixture = createComponent ( GridListWithFitRowHeightMode ) ;
130107
131- if ( disableComputedStyleTests ) {
132- return ;
133- }
134-
135108 fixture . componentInstance . totalHeight = '300px' ;
136109 fixture . detectChanges ( ) ;
137110 const tile = fixture . debugElement . query ( By . directive ( MatGridTile ) ) ! ;
@@ -149,10 +122,6 @@ describe('MatGridList', () => {
149122 it ( 'should use the fixed row height if passed in' , ( ) => {
150123 const fixture = createComponent ( GridListWithFixedRowHeightMode ) ;
151124
152- if ( disableComputedStyleTests ) {
153- return ;
154- }
155-
156125 fixture . componentInstance . rowHeight = '100px' ;
157126 fixture . detectChanges ( ) ;
158127
@@ -168,10 +137,6 @@ describe('MatGridList', () => {
168137 it ( 'should default to pixels if row height units are missing' , ( ) => {
169138 const fixture = createComponent ( GridListWithUnitlessFixedRowHeight ) ;
170139
171- if ( disableComputedStyleTests ) {
172- return ;
173- }
174-
175140 fixture . detectChanges ( ) ;
176141 const tile = fixture . debugElement . query ( By . directive ( MatGridTile ) ) ! ;
177142 expect ( getDimension ( tile , 'height' ) ) . toBe ( 100 ) ;
@@ -180,10 +145,6 @@ describe('MatGridList', () => {
180145 it ( 'should default gutter size to 1px' , ( ) => {
181146 const fixture = createComponent ( GridListWithUnspecifiedGutterSize ) ;
182147
183- if ( disableComputedStyleTests ) {
184- return ;
185- }
186-
187148 fixture . detectChanges ( ) ;
188149 const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
189150
@@ -200,10 +161,6 @@ describe('MatGridList', () => {
200161 const fixture = createComponent ( GridListWithUnspecifiedGutterSize ) ;
201162 const gridList = fixture . debugElement . query ( By . directive ( MatGridList ) ) ! ;
202163
203- if ( disableComputedStyleTests ) {
204- return ;
205- }
206-
207164 gridList . componentInstance . gutterSize = 0 ;
208165 fixture . detectChanges ( ) ;
209166
@@ -221,10 +178,6 @@ describe('MatGridList', () => {
221178 it ( 'should lay out the tiles correctly for a nested grid list' , ( ) => {
222179 const fixture = createComponent ( NestedGridList ) ;
223180
224- if ( disableComputedStyleTests ) {
225- return ;
226- }
227-
228181 fixture . detectChanges ( ) ;
229182 const innerTiles = fixture . debugElement . queryAll (
230183 By . css ( 'mat-grid-tile mat-grid-list mat-grid-tile' ) ,
@@ -238,10 +191,6 @@ describe('MatGridList', () => {
238191 it ( 'should set the gutter size if passed' , ( ) => {
239192 const fixture = createComponent ( GridListWithGutterSize ) ;
240193
241- if ( disableComputedStyleTests ) {
242- return ;
243- }
244-
245194 fixture . detectChanges ( ) ;
246195 const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
247196
@@ -257,10 +206,6 @@ describe('MatGridList', () => {
257206 it ( 'should use pixels if gutter units are missing' , ( ) => {
258207 const fixture = createComponent ( GridListWithUnitlessGutterSize ) ;
259208
260- if ( disableComputedStyleTests ) {
261- return ;
262- }
263-
264209 fixture . detectChanges ( ) ;
265210 const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
266211
@@ -277,10 +222,6 @@ describe('MatGridList', () => {
277222 const fixture = createComponent ( GridListWithUnspecifiedGutterSize ) ;
278223 const gridList = fixture . debugElement . query ( By . directive ( MatGridList ) ) ! ;
279224
280- if ( disableComputedStyleTests ) {
281- return ;
282- }
283-
284225 gridList . componentInstance . gutterSize = '10%' ;
285226 fixture . detectChanges ( ) ;
286227
@@ -293,10 +234,6 @@ describe('MatGridList', () => {
293234 it ( 'should set the correct list height in ratio mode' , ( ) => {
294235 const fixture = createComponent ( GridListWithRatioHeightAndMulipleRows ) ;
295236
296- if ( disableComputedStyleTests ) {
297- return ;
298- }
299-
300237 fixture . detectChanges ( ) ;
301238 const list = fixture . debugElement . query ( By . directive ( MatGridList ) ) ! ;
302239 const inlineStyles = list . nativeElement . style ;
@@ -309,10 +246,6 @@ describe('MatGridList', () => {
309246 it ( 'should set the correct list height in fixed mode' , ( ) => {
310247 const fixture = createComponent ( GridListWithFixRowHeightAndMultipleRows ) ;
311248
312- if ( disableComputedStyleTests ) {
313- return ;
314- }
315-
316249 fixture . detectChanges ( ) ;
317250 const list = fixture . debugElement . query ( By . directive ( MatGridList ) ) ! ;
318251 expect ( getDimension ( list , 'height' ) ) . toBe ( 201 ) ;
@@ -321,10 +254,6 @@ describe('MatGridList', () => {
321254 it ( 'should allow adjustment of tile colspan' , ( ) => {
322255 const fixture = createComponent ( GridListWithColspanBinding ) ;
323256
324- if ( disableComputedStyleTests ) {
325- return ;
326- }
327-
328257 fixture . componentInstance . colspan = 2 ;
329258 fixture . detectChanges ( ) ;
330259
@@ -339,10 +268,6 @@ describe('MatGridList', () => {
339268 it ( 'should allow adjustment of tile rowspan' , ( ) => {
340269 const fixture = createComponent ( GridListWithRowspanBinding ) ;
341270
342- if ( disableComputedStyleTests ) {
343- return ;
344- }
345-
346271 fixture . componentInstance . rowspan = 2 ;
347272 fixture . detectChanges ( ) ;
348273
@@ -357,10 +282,6 @@ describe('MatGridList', () => {
357282 it ( 'should lay out tiles correctly for a complex layout' , ( ) => {
358283 const fixture = createComponent ( GridListWithComplexLayout ) ;
359284
360- if ( disableComputedStyleTests ) {
361- return ;
362- }
363-
364285 fixture . componentInstance . tiles = [
365286 { cols : 3 , rows : 1 } ,
366287 { cols : 1 , rows : 2 } ,
@@ -395,10 +316,6 @@ describe('MatGridList', () => {
395316 it ( 'should lay out tiles correctly' , ( ) => {
396317 const fixture = createComponent ( GridListWithLayout ) ;
397318
398- if ( disableComputedStyleTests ) {
399- return ;
400- }
401-
402319 fixture . detectChanges ( ) ;
403320 const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
404321
@@ -431,10 +348,6 @@ describe('MatGridList', () => {
431348 it ( 'should lay out tiles correctly when single cell to be placed at the beginning' , ( ) => {
432349 const fixture = createComponent ( GridListWithSingleCellAtBeginning ) ;
433350
434- if ( disableComputedStyleTests ) {
435- return ;
436- }
437-
438351 fixture . detectChanges ( ) ;
439352 const tiles = fixture . debugElement . queryAll ( By . css ( 'mat-grid-tile' ) ) ;
440353
@@ -497,10 +410,6 @@ describe('MatGridList', () => {
497410 it ( 'should reset the old styles when switching to a new tile styler' , ( ) => {
498411 const fixture = createComponent ( GirdListWithRowHeightRatio ) ;
499412
500- if ( disableComputedStyleTests ) {
501- return ;
502- }
503-
504413 fixture . componentInstance . rowHeight = '4:1' ;
505414 fixture . detectChanges ( ) ;
506415
@@ -562,10 +471,6 @@ describe('MatGridList', () => {
562471 it ( 'should lay out the tiles if they are not direct descendants of the list' , ( ) => {
563472 const fixture = createComponent ( GridListWithIndirectTileDescendants ) ;
564473
565- if ( disableComputedStyleTests ) {
566- return ;
567- }
568-
569474 fixture . detectChanges ( ) ;
570475 const tile = fixture . debugElement . query ( By . directive ( MatGridTile ) ) ! ;
571476 const inlineStyles = tile . nativeElement . style ;
0 commit comments