@@ -3,6 +3,7 @@ import {Component, DebugElement} from '@angular/core';
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { MatGridList , MatGridListModule } from './index' ;
5
5
import { MatGridTile , MatGridTileText } from './grid-tile' ;
6
+ import { Directionality } from '@angular/cdk/bidi' ;
6
7
7
8
8
9
describe ( 'MatGridList' , ( ) => {
@@ -29,6 +30,8 @@ describe('MatGridList', () => {
29
30
GridListWithFootersWithoutLines ,
30
31
GridListWithFooterContainingTwoLines ,
31
32
GridListWithoutMatchingGap ,
33
+ GridListWithEmptyDirectionality ,
34
+ GridListWithRtl ,
32
35
] ,
33
36
} ) ;
34
37
@@ -297,6 +300,23 @@ describe('MatGridList', () => {
297
300
. toBe ( true , 'Expected none of the tiles to have a negative `left`' ) ;
298
301
} ) ;
299
302
303
+ it ( 'should default to LTR if empty directionality is given' , ( ) => {
304
+ const fixture = TestBed . createComponent ( GridListWithEmptyDirectionality ) ;
305
+ const tile : HTMLElement = fixture . debugElement . query ( By . css ( 'mat-grid-tile' ) ) . nativeElement ;
306
+ fixture . detectChanges ( ) ;
307
+
308
+ expect ( tile . style . left ) . toBe ( '0px' ) ;
309
+ expect ( tile . style . right ) . toBe ( '' ) ;
310
+ } ) ;
311
+
312
+ it ( 'should set `right` styles for RTL' , ( ) => {
313
+ const fixture = TestBed . createComponent ( GridListWithRtl ) ;
314
+ const tile : HTMLElement = fixture . debugElement . query ( By . css ( 'mat-grid-tile' ) ) . nativeElement ;
315
+ fixture . detectChanges ( ) ;
316
+
317
+ expect ( tile . style . left ) . toBe ( '' ) ;
318
+ expect ( tile . style . right ) . toBe ( '0px' ) ;
319
+ } ) ;
300
320
} ) ;
301
321
302
322
@@ -317,7 +337,6 @@ function getComputedLeft(element: DebugElement): number {
317
337
}
318
338
319
339
320
-
321
340
@Component ( { template : '<mat-grid-list></mat-grid-list>' } )
322
341
class GridListWithoutCols { }
323
342
@@ -478,3 +497,15 @@ class GridListWithFooterContainingTwoLines { }
478
497
</mat-grid-list>
479
498
` } )
480
499
class GridListWithoutMatchingGap { }
500
+
501
+ @Component ( {
502
+ template : `<mat-grid-list cols="1"><mat-grid-tile>Hello</mat-grid-tile></mat-grid-list>` ,
503
+ providers : [ { provide : Directionality , useValue : { } } ]
504
+ } )
505
+ class GridListWithEmptyDirectionality { }
506
+
507
+ @Component ( {
508
+ template : `<mat-grid-list cols="1"><mat-grid-tile>Hello</mat-grid-tile></mat-grid-list>` ,
509
+ providers : [ { provide : Directionality , useValue : { value : 'rtl' } } ]
510
+ } )
511
+ class GridListWithRtl { }
0 commit comments