@@ -23,7 +23,7 @@ import {dispatchFakeEvent} from '../core/testing/dispatch-events';
23
23
24
24
describe ( 'MdSelect' , ( ) => {
25
25
let overlayContainerElement : HTMLElement ;
26
- let dir : { value : string } ;
26
+ let dir : { value : 'ltr' | 'rtl' } ;
27
27
28
28
beforeEach ( async ( ( ) => {
29
29
TestBed . configureTestingModule ( {
@@ -1553,6 +1553,23 @@ describe('MdSelect', () => {
1553
1553
expect ( fixture . componentInstance . control . value ) . toEqual ( [ 'steak-0' , 'pizza-1' , 'tacos-2' ] ) ;
1554
1554
} ) ;
1555
1555
1556
+ it ( 'should sort the selected options in reverse in rtl' , ( ) => {
1557
+ dir . value = 'rtl' ;
1558
+ trigger . click ( ) ;
1559
+ fixture . detectChanges ( ) ;
1560
+
1561
+ const options = overlayContainerElement . querySelectorAll ( 'md-option' ) as
1562
+ NodeListOf < HTMLElement > ;
1563
+
1564
+ options [ 2 ] . click ( ) ;
1565
+ options [ 0 ] . click ( ) ;
1566
+ options [ 1 ] . click ( ) ;
1567
+ fixture . detectChanges ( ) ;
1568
+
1569
+ expect ( trigger . textContent ) . toContain ( 'Tacos, Pizza, Steak' ) ;
1570
+ expect ( fixture . componentInstance . control . value ) . toEqual ( [ 'steak-0' , 'pizza-1' , 'tacos-2' ] ) ;
1571
+ } ) ;
1572
+
1556
1573
it ( 'should sort the values, that get set via the model, based on the panel order' , ( ) => {
1557
1574
trigger . click ( ) ;
1558
1575
fixture . detectChanges ( ) ;
@@ -1563,6 +1580,17 @@ describe('MdSelect', () => {
1563
1580
expect ( trigger . textContent ) . toContain ( 'Steak, Pizza, Tacos' ) ;
1564
1581
} ) ;
1565
1582
1583
+ it ( 'should reverse sort the values, that get set via the model in rtl' , ( ) => {
1584
+ dir . value = 'rtl' ;
1585
+ trigger . click ( ) ;
1586
+ fixture . detectChanges ( ) ;
1587
+
1588
+ testInstance . control . setValue ( [ 'tacos-2' , 'steak-0' , 'pizza-1' ] ) ;
1589
+ fixture . detectChanges ( ) ;
1590
+
1591
+ expect ( trigger . textContent ) . toContain ( 'Tacos, Pizza, Steak' ) ;
1592
+ } ) ;
1593
+
1566
1594
it ( 'should throw an exception when trying to set a non-array value' , ( ) => {
1567
1595
expect ( ( ) => {
1568
1596
testInstance . control . setValue ( 'not-an-array' ) ;
0 commit comments