@@ -26,7 +26,7 @@ import {wrappedErrorMessage} from '../core/testing/wrapped-error-message';
26
26
27
27
describe ( 'MdSelect' , ( ) => {
28
28
let overlayContainerElement : HTMLElement ;
29
- let dir : { value : string } ;
29
+ let dir : { value : 'ltr' | 'rtl' } ;
30
30
31
31
beforeEach ( async ( ( ) => {
32
32
TestBed . configureTestingModule ( {
@@ -1571,6 +1571,23 @@ describe('MdSelect', () => {
1571
1571
expect ( fixture . componentInstance . control . value ) . toEqual ( [ 'steak-0' , 'pizza-1' , 'tacos-2' ] ) ;
1572
1572
} ) ;
1573
1573
1574
+ it ( 'should sort the selected options in reverse in rtl' , ( ) => {
1575
+ dir . value = 'rtl' ;
1576
+ trigger . click ( ) ;
1577
+ fixture . detectChanges ( ) ;
1578
+
1579
+ const options = overlayContainerElement . querySelectorAll ( 'md-option' ) as
1580
+ NodeListOf < HTMLElement > ;
1581
+
1582
+ options [ 2 ] . click ( ) ;
1583
+ options [ 0 ] . click ( ) ;
1584
+ options [ 1 ] . click ( ) ;
1585
+ fixture . detectChanges ( ) ;
1586
+
1587
+ expect ( trigger . textContent ) . toContain ( 'Tacos, Pizza, Steak' ) ;
1588
+ expect ( fixture . componentInstance . control . value ) . toEqual ( [ 'steak-0' , 'pizza-1' , 'tacos-2' ] ) ;
1589
+ } ) ;
1590
+
1574
1591
it ( 'should sort the values, that get set via the model, based on the panel order' , ( ) => {
1575
1592
trigger . click ( ) ;
1576
1593
fixture . detectChanges ( ) ;
@@ -1581,6 +1598,17 @@ describe('MdSelect', () => {
1581
1598
expect ( trigger . textContent ) . toContain ( 'Steak, Pizza, Tacos' ) ;
1582
1599
} ) ;
1583
1600
1601
+ it ( 'should reverse sort the values, that get set via the model in rtl' , ( ) => {
1602
+ dir . value = 'rtl' ;
1603
+ trigger . click ( ) ;
1604
+ fixture . detectChanges ( ) ;
1605
+
1606
+ testInstance . control . setValue ( [ 'tacos-2' , 'steak-0' , 'pizza-1' ] ) ;
1607
+ fixture . detectChanges ( ) ;
1608
+
1609
+ expect ( trigger . textContent ) . toContain ( 'Tacos, Pizza, Steak' ) ;
1610
+ } ) ;
1611
+
1584
1612
it ( 'should throw an exception when trying to set a non-array value' , ( ) => {
1585
1613
expect ( ( ) => {
1586
1614
testInstance . control . setValue ( 'not-an-array' ) ;
0 commit comments