@@ -11,7 +11,7 @@ import {
11
11
} from '@angular/cdk/keycodes' ;
12
12
import { StepperOrientation } from '@angular/cdk/stepper' ;
13
13
import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
14
- import { Component , DebugElement } from '@angular/core' ;
14
+ import { Component , DebugElement , EventEmitter } from '@angular/core' ;
15
15
import { async , ComponentFixture , inject , TestBed , fakeAsync , flush } from '@angular/core/testing' ;
16
16
import {
17
17
AbstractControl ,
@@ -35,10 +35,13 @@ import {MatStepperIntl} from './stepper-intl';
35
35
const VALID_REGEX = / v a l i d / ;
36
36
37
37
describe ( 'MatStepper' , ( ) => {
38
- let dir : Direction ;
38
+ let dir : { value : Direction , change : EventEmitter < Direction > } ;
39
39
40
40
beforeEach ( async ( ( ) => {
41
- dir = 'ltr' ;
41
+ dir = {
42
+ value : 'ltr' ,
43
+ change : new EventEmitter ( )
44
+ } ;
42
45
43
46
TestBed . configureTestingModule ( {
44
47
imports : [ MatStepperModule , NoopAnimationsModule , ReactiveFormsModule ] ,
@@ -53,7 +56,7 @@ describe('MatStepper', () => {
53
56
LinearStepperWithValidOptionalStep ,
54
57
] ,
55
58
providers : [
56
- { provide : Directionality , useFactory : ( ) => ( { value : dir } ) }
59
+ { provide : Directionality , useFactory : ( ) => dir }
57
60
]
58
61
} ) ;
59
62
@@ -410,7 +413,7 @@ describe('MatStepper', () => {
410
413
let fixture : ComponentFixture < SimpleMatVerticalStepperApp > ;
411
414
412
415
beforeEach ( ( ) => {
413
- dir = 'rtl' ;
416
+ dir . value = 'rtl' ;
414
417
fixture = TestBed . createComponent ( SimpleMatVerticalStepperApp ) ;
415
418
fixture . detectChanges ( ) ;
416
419
} ) ;
@@ -739,7 +742,7 @@ describe('MatStepper', () => {
739
742
} ) ;
740
743
741
744
it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
742
- dir = 'rtl' ;
745
+ dir . value = 'rtl' ;
743
746
let fixture = TestBed . createComponent ( SimpleMatVerticalStepperApp ) ;
744
747
fixture . detectChanges ( ) ;
745
748
@@ -766,13 +769,27 @@ describe('MatStepper', () => {
766
769
} ) ;
767
770
768
771
it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
769
- dir = 'rtl' ;
772
+ dir . value = 'rtl' ;
770
773
let fixture = TestBed . createComponent ( SimpleMatHorizontalStepperApp ) ;
771
774
fixture . detectChanges ( ) ;
772
775
773
776
let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
774
777
assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
775
778
} ) ;
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
+ } ) ;
776
793
} ) ;
777
794
778
795
describe ( 'valid step in linear stepper' , ( ) => {
0 commit comments