@@ -811,24 +811,26 @@ function assertEditableStepChange(fixture: ComponentFixture<any>) {
811
811
}
812
812
813
813
/**
814
- * Asserts that it is possible to skip an optional step in linear stepper if there is no input
815
- * or the input is valid .
814
+ * Asserts that it is possible to skip an optional step in linear
815
+ * stepper if there is no input or the input is invalid .
816
816
*/
817
817
function assertOptionalStepValidity ( testComponent :
818
818
LinearMatHorizontalStepperApp | LinearMatVerticalStepperApp ,
819
819
fixture : ComponentFixture < any > ) {
820
- let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) . componentInstance ;
820
+ const stepperComponent : MatStepper = fixture . debugElement
821
+ . query ( By . directive ( MatStepper ) ) . componentInstance ;
821
822
822
823
testComponent . oneGroup . get ( 'oneCtrl' ) ! . setValue ( 'input' ) ;
823
824
testComponent . twoGroup . get ( 'twoCtrl' ) ! . setValue ( 'input' ) ;
824
825
testComponent . validationTrigger . next ( ) ;
825
826
stepperComponent . selectedIndex = 2 ;
826
827
fixture . detectChanges ( ) ;
827
828
829
+ expect ( stepperComponent . _steps . toArray ( ) [ 2 ] . optional ) . toBe ( true ) ;
828
830
expect ( stepperComponent . selectedIndex ) . toBe ( 2 ) ;
829
831
expect ( testComponent . threeGroup . get ( 'threeCtrl' ) ! . valid ) . toBe ( true ) ;
830
832
831
- let nextButtonNativeEl = fixture . debugElement
833
+ const nextButtonNativeEl = fixture . debugElement
832
834
. queryAll ( By . directive ( MatStepperNext ) ) [ 2 ] . nativeElement ;
833
835
nextButtonNativeEl . click ( ) ;
834
836
fixture . detectChanges ( ) ;
@@ -843,15 +845,7 @@ function assertOptionalStepValidity(testComponent:
843
845
844
846
expect ( testComponent . threeGroup . get ( 'threeCtrl' ) ! . valid ) . toBe ( false ) ;
845
847
expect ( stepperComponent . selectedIndex )
846
- . toBe ( 2 , 'Expected selectedIndex to remain unchanged when optional step input is invalid.' ) ;
847
-
848
- testComponent . threeGroup . get ( 'threeCtrl' ) ! . setValue ( 'valid' ) ;
849
- nextButtonNativeEl . click ( ) ;
850
- fixture . detectChanges ( ) ;
851
-
852
- expect ( testComponent . threeGroup . get ( 'threeCtrl' ) ! . valid ) . toBe ( true ) ;
853
- expect ( stepperComponent . selectedIndex )
854
- . toBe ( 3 , 'Expected selectedIndex to change when optional step input is valid.' ) ;
848
+ . toBe ( 3 , 'Expected selectedIndex to change when optional step input is invalid.' ) ;
855
849
}
856
850
857
851
/** Asserts that step header set the correct icon depending on the state of step. */
@@ -872,10 +866,7 @@ function assertCorrectStepIcon(fixture: ComponentFixture<any>,
872
866
function asyncValidator ( minLength : number , validationTrigger : Observable < any > ) : AsyncValidatorFn {
873
867
return ( control : AbstractControl ) : Observable < ValidationErrors | null > => {
874
868
return validationTrigger . pipe (
875
- map ( ( ) => {
876
- const success = control . value && control . value . length >= minLength ;
877
- return success ? null : { 'asyncValidation' : { } } ;
878
- } ) ,
869
+ map ( ( ) => control . value && control . value . length >= minLength ? null : { asyncValidation : { } } ) ,
879
870
take ( 1 )
880
871
) ;
881
872
} ;
0 commit comments