@@ -3,6 +3,7 @@ import {Component, DebugElement} from '@angular/core';
33import { By } from '@angular/platform-browser' ;
44import { MatGridList , MatGridListModule } from './index' ;
55import { MatGridTile , MatGridTileText } from './grid-tile' ;
6+ import { Directionality } from '@angular/cdk/bidi' ;
67
78
89describe ( 'MatGridList' , ( ) => {
@@ -29,6 +30,8 @@ describe('MatGridList', () => {
2930 GridListWithFootersWithoutLines ,
3031 GridListWithFooterContainingTwoLines ,
3132 GridListWithoutMatchingGap ,
33+ GridListWithEmptyDirectionality ,
34+ GridListWithRtl ,
3235 ] ,
3336 } ) ;
3437
@@ -297,6 +300,23 @@ describe('MatGridList', () => {
297300 . toBe ( true , 'Expected none of the tiles to have a negative `left`' ) ;
298301 } ) ;
299302
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+ } ) ;
300320} ) ;
301321
302322
@@ -317,7 +337,6 @@ function getComputedLeft(element: DebugElement): number {
317337}
318338
319339
320-
321340@Component ( { template : '<mat-grid-list></mat-grid-list>' } )
322341class GridListWithoutCols { }
323342
@@ -478,3 +497,15 @@ class GridListWithFooterContainingTwoLines { }
478497 </mat-grid-list>
479498` } )
480499class 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