@@ -780,24 +780,26 @@ function assertEditableStepChange(fixture: ComponentFixture<any>) {
780
780
}
781
781
782
782
/**
783
- * Asserts that it is possible to skip an optional step in linear stepper if there is no input
784
- * or the input is valid .
783
+ * Asserts that it is possible to skip an optional step in linear
784
+ * stepper if there is no input or the input is invalid .
785
785
*/
786
786
function assertOptionalStepValidity ( testComponent :
787
787
LinearMatHorizontalStepperApp | LinearMatVerticalStepperApp ,
788
788
fixture : ComponentFixture < any > ) {
789
- let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) . componentInstance ;
789
+ const stepperComponent : MatStepper = fixture . debugElement
790
+ . query ( By . directive ( MatStepper ) ) . componentInstance ;
790
791
791
792
testComponent . oneGroup . get ( 'oneCtrl' ) ! . setValue ( 'input' ) ;
792
793
testComponent . twoGroup . get ( 'twoCtrl' ) ! . setValue ( 'input' ) ;
793
794
testComponent . validationTrigger . next ( ) ;
794
795
stepperComponent . selectedIndex = 2 ;
795
796
fixture . detectChanges ( ) ;
796
797
798
+ expect ( stepperComponent . _steps . toArray ( ) [ 2 ] . optional ) . toBe ( true ) ;
797
799
expect ( stepperComponent . selectedIndex ) . toBe ( 2 ) ;
798
800
expect ( testComponent . threeGroup . get ( 'threeCtrl' ) ! . valid ) . toBe ( true ) ;
799
801
800
- let nextButtonNativeEl = fixture . debugElement
802
+ const nextButtonNativeEl = fixture . debugElement
801
803
. queryAll ( By . directive ( MatStepperNext ) ) [ 2 ] . nativeElement ;
802
804
nextButtonNativeEl . click ( ) ;
803
805
fixture . detectChanges ( ) ;
@@ -812,15 +814,7 @@ function assertOptionalStepValidity(testComponent:
812
814
813
815
expect ( testComponent . threeGroup . get ( 'threeCtrl' ) ! . valid ) . toBe ( false ) ;
814
816
expect ( stepperComponent . selectedIndex )
815
- . toBe ( 2 , 'Expected selectedIndex to remain unchanged when optional step input is invalid.' ) ;
816
-
817
- testComponent . threeGroup . get ( 'threeCtrl' ) ! . setValue ( 'valid' ) ;
818
- nextButtonNativeEl . click ( ) ;
819
- fixture . detectChanges ( ) ;
820
-
821
- expect ( testComponent . threeGroup . get ( 'threeCtrl' ) ! . valid ) . toBe ( true ) ;
822
- expect ( stepperComponent . selectedIndex )
823
- . toBe ( 3 , 'Expected selectedIndex to change when optional step input is valid.' ) ;
817
+ . toBe ( 3 , 'Expected selectedIndex to change when optional step input is invalid.' ) ;
824
818
}
825
819
826
820
/** Asserts that step header set the correct icon depending on the state of step. */
@@ -841,10 +835,7 @@ function assertCorrectStepIcon(fixture: ComponentFixture<any>,
841
835
function asyncValidator ( minLength : number , validationTrigger : Observable < any > ) : AsyncValidatorFn {
842
836
return ( control : AbstractControl ) : Observable < ValidationErrors | null > => {
843
837
return validationTrigger . pipe (
844
- map ( ( ) => {
845
- const success = control . value && control . value . length >= minLength ;
846
- return success ? null : { 'asyncValidation' : { } } ;
847
- } ) ,
838
+ map ( ( ) => control . value && control . value . length >= minLength ? null : { asyncValidation : { } } ) ,
848
839
take ( 1 )
849
840
) ;
850
841
} ;
0 commit comments