@@ -11,7 +11,7 @@ import {
1111} from '@angular/cdk/keycodes' ;
1212import { StepperOrientation } from '@angular/cdk/stepper' ;
1313import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
14- import { Component , DebugElement } from '@angular/core' ;
14+ import { Component , DebugElement , EventEmitter } from '@angular/core' ;
1515import { async , ComponentFixture , inject , TestBed , fakeAsync , flush } from '@angular/core/testing' ;
1616import {
1717 AbstractControl ,
@@ -35,10 +35,13 @@ import {MatStepperIntl} from './stepper-intl';
3535const VALID_REGEX = / v a l i d / ;
3636
3737describe ( 'MatStepper' , ( ) => {
38- let dir : Direction ;
38+ let dir : { value : Direction , change : EventEmitter < Direction > } ;
3939
4040 beforeEach ( async ( ( ) => {
41- dir = 'ltr' ;
41+ dir = {
42+ value : 'ltr' ,
43+ change : new EventEmitter ( )
44+ } ;
4245
4346 TestBed . configureTestingModule ( {
4447 imports : [ MatStepperModule , NoopAnimationsModule , ReactiveFormsModule ] ,
@@ -53,7 +56,7 @@ describe('MatStepper', () => {
5356 LinearStepperWithValidOptionalStep ,
5457 ] ,
5558 providers : [
56- { provide : Directionality , useFactory : ( ) => ( { value : dir } ) }
59+ { provide : Directionality , useFactory : ( ) => dir }
5760 ]
5861 } ) ;
5962
@@ -410,7 +413,7 @@ describe('MatStepper', () => {
410413 let fixture : ComponentFixture < SimpleMatVerticalStepperApp > ;
411414
412415 beforeEach ( ( ) => {
413- dir = 'rtl' ;
416+ dir . value = 'rtl' ;
414417 fixture = TestBed . createComponent ( SimpleMatVerticalStepperApp ) ;
415418 fixture . detectChanges ( ) ;
416419 } ) ;
@@ -739,7 +742,7 @@ describe('MatStepper', () => {
739742 } ) ;
740743
741744 it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
742- dir = 'rtl' ;
745+ dir . value = 'rtl' ;
743746 let fixture = TestBed . createComponent ( SimpleMatVerticalStepperApp ) ;
744747 fixture . detectChanges ( ) ;
745748
@@ -766,13 +769,27 @@ describe('MatStepper', () => {
766769 } ) ;
767770
768771 it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
769- dir = 'rtl' ;
772+ dir . value = 'rtl' ;
770773 let fixture = TestBed . createComponent ( SimpleMatHorizontalStepperApp ) ;
771774 fixture . detectChanges ( ) ;
772775
773776 let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
774777 assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
775778 } ) ;
779+
780+ it ( 'should reverse arrow key focus when switching into RTL after init' , ( ) => {
781+ let fixture = TestBed . createComponent ( SimpleMatHorizontalStepperApp ) ;
782+ fixture . detectChanges ( ) ;
783+
784+ let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
785+ assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
786+
787+ dir . value = 'rtl' ;
788+ dir . change . emit ( 'rtl' ) ;
789+ fixture . detectChanges ( ) ;
790+
791+ assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
792+ } ) ;
776793 } ) ;
777794
778795 describe ( 'valid step in linear stepper' , ( ) => {
0 commit comments