@@ -26,7 +26,7 @@ import {wrappedErrorMessage} from '../core/testing/wrapped-error-message';
2626
2727describe ( 'MdSelect' , ( ) => {
2828 let overlayContainerElement : HTMLElement ;
29- let dir : { value : string } ;
29+ let dir : { value : 'ltr' | 'rtl' } ;
3030
3131 beforeEach ( async ( ( ) => {
3232 TestBed . configureTestingModule ( {
@@ -1571,6 +1571,23 @@ describe('MdSelect', () => {
15711571 expect ( fixture . componentInstance . control . value ) . toEqual ( [ 'steak-0' , 'pizza-1' , 'tacos-2' ] ) ;
15721572 } ) ;
15731573
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+
15741591 it ( 'should sort the values, that get set via the model, based on the panel order' , ( ) => {
15751592 trigger . click ( ) ;
15761593 fixture . detectChanges ( ) ;
@@ -1581,6 +1598,17 @@ describe('MdSelect', () => {
15811598 expect ( trigger . textContent ) . toContain ( 'Steak, Pizza, Tacos' ) ;
15821599 } ) ;
15831600
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+
15841612 it ( 'should throw an exception when trying to set a non-array value' , ( ) => {
15851613 expect ( ( ) => {
15861614 testInstance . control . setValue ( 'not-an-array' ) ;
0 commit comments