@@ -440,11 +440,19 @@ describe('Rendering Tests', () => {
440
440
it ( 'should place the title in the step element according to the specified titlePosition when stepType is set to "full"' , ( ) => {
441
441
stepper . orientation = IgxStepperOrientation . Horizontal ;
442
442
stepper . stepType = IgxStepType . Full ;
443
+ stepper . titlePosition = null ;
443
444
fix . detectChanges ( ) ;
444
445
445
- let positions = getStepperPositions ( ) ;
446
+ //test default title positions
447
+ for ( const step of stepper . steps ) {
448
+ expect ( step . titlePosition ) . toBe ( stepper . _defaultTitlePosition ) ;
449
+ expect ( step . titlePosition ) . toBe ( IgxStepperTitlePosition . Bottom ) ;
450
+ expect ( step . nativeElement ) . toHaveClass ( `igx-stepper__step--${ stepper . _defaultTitlePosition } ` ) ;
451
+ }
452
+
453
+ const positions = getStepperPositions ( ) ;
446
454
positions . forEach ( ( pos : IgxStepperTitlePosition ) => {
447
- stepper . horizontalTitlePosition = pos ;
455
+ stepper . titlePosition = pos ;
448
456
fix . detectChanges ( ) ;
449
457
450
458
for ( const step of stepper . steps ) {
@@ -453,11 +461,18 @@ describe('Rendering Tests', () => {
453
461
} ) ;
454
462
455
463
stepper . orientation = IgxStepperOrientation . Vertical ;
464
+ stepper . titlePosition = null ;
456
465
fix . detectChanges ( ) ;
457
466
458
- positions = getStepperPositions ( ) ;
467
+ //test default title positions
468
+ for ( const step of stepper . steps ) {
469
+ expect ( step . titlePosition ) . toBe ( stepper . _defaultTitlePosition ) ;
470
+ expect ( step . titlePosition ) . toBe ( IgxStepperTitlePosition . End ) ;
471
+ expect ( step . nativeElement ) . toHaveClass ( `igx-stepper__step--${ stepper . _defaultTitlePosition } ` ) ;
472
+ }
473
+
459
474
positions . forEach ( ( pos : IgxStepperTitlePosition ) => {
460
- stepper . verticalTitlePosition = pos ;
475
+ stepper . titlePosition = pos ;
461
476
fix . detectChanges ( ) ;
462
477
463
478
for ( const step of stepper . steps ) {
@@ -544,20 +559,11 @@ describe('Rendering Tests', () => {
544
559
testAnimationBehvior ( val , fix , false ) ;
545
560
}
546
561
547
- const dummyTestValues = [ - 1 , 'sampleString' , [ ] , { } ] ;
548
-
549
- for ( const val of dummyTestValues ) {
550
- expect ( ( ) => {
551
- fix . componentInstance . animationDuration = val as any ;
552
- testAnimationBehvior ( val , fix , false ) ;
553
- } ) . toThrow ( ) ;
554
- }
555
-
556
- const fallbackToDefaultValues = [ 0 , null ] ;
562
+ const fallbackToDefaultValues = [ - 1 , 0 , null , undefined , 'sampleString' , [ ] , { } ] ;
557
563
for ( const val of fallbackToDefaultValues ) {
558
564
fix . componentInstance . animationDuration = val as any ;
559
565
fix . detectChanges ( ) ;
560
- expect ( stepper . animationDuration ) . withContext ( 'Set 0/null animation duration and verify default value' )
566
+ expect ( stepper . animationDuration )
561
567
. toBe ( ( stepper as any ) . _defaultAnimationDuration ) ;
562
568
testAnimationBehvior ( val , fix , false ) ;
563
569
}
@@ -926,9 +932,7 @@ describe('Stepper service unit tests', () => {
926
932
mockElementRef = { nativeElement : mockElement } ;
927
933
928
934
mockAnimationBuilder = {
929
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
930
935
build : ( _a : AnimationMetadata | AnimationMetadata [ ] ) => ( {
931
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
932
936
create : ( _e : any , _opt ?: AnimationOptions ) => ( {
933
937
onDone : ( _fn : any ) => { } ,
934
938
onStart : ( _fn : any ) => { } ,
@@ -950,7 +954,6 @@ describe('Stepper service unit tests', () => {
950
954
} )
951
955
} ;
952
956
953
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
954
957
mockPlatform = { isIOS : false } ;
955
958
956
959
mockDocument = {
@@ -962,14 +965,12 @@ describe('Stepper service unit tests', () => {
962
965
removeEventListener : ( _type : string , _listener : ( this : HTMLElement , ev : MouseEvent ) => any ) => { }
963
966
} ;
964
967
965
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
966
968
mockDir = {
967
969
value : ( ) : Direction => 'rtl' ,
968
970
document : ( ) => mockDocument ,
969
971
rtl : ( ) => true
970
972
} ;
971
973
972
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
973
974
mockCdr = {
974
975
markForCheck : ( ) : void => { } ,
975
976
detach : ( ) : void => { } ,
@@ -989,16 +990,8 @@ describe('Stepper service unit tests', () => {
989
990
}
990
991
} ) ;
991
992
992
- it ( 'should properly register the specified stepper' , ( ) => {
993
- stepperService = new IgxStepperService ( ) ;
994
- expect ( ( stepperService as any ) . stepper ) . toBeFalsy ( ) ;
995
- stepperService . register ( stepper ) ;
996
- expect ( ( stepperService as any ) . stepper ) . toEqual ( stepper ) ;
997
- } ) ;
998
-
999
993
it ( 'should expand a step by activating it and firing the step\'s activeChange event' , ( ) => {
1000
994
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Horizontal ) ;
1001
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Horizontal ) ;
1002
995
spyOnProperty ( stepper , 'steps' , 'get' ) . and . returnValue ( steps ) ;
1003
996
1004
997
stepperService . activeStep = steps [ 0 ] ;
@@ -1015,12 +1008,10 @@ describe('Stepper service unit tests', () => {
1015
1008
expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledWith ( true ) ;
1016
1009
1017
1010
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Vertical ) ;
1018
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Vertical ) ;
1019
1011
stepperService . expand ( steps [ 0 ] ) ;
1020
1012
1021
1013
expect ( stepperService . activeStep ) . toBe ( steps [ 0 ] ) ;
1022
- expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1023
- expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledWith ( true ) ;
1014
+ expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledOnceWith ( true ) ;
1024
1015
1025
1016
const testValues = [ null , undefined , [ ] , { } , 'sampleString' ] ;
1026
1017
@@ -1033,7 +1024,6 @@ describe('Stepper service unit tests', () => {
1033
1024
1034
1025
it ( 'should expand a step through API by activating it and firing the step\'s activeChange event' , ( ) => {
1035
1026
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Horizontal ) ;
1036
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Horizontal ) ;
1037
1027
spyOnProperty ( stepper , 'steps' , 'get' ) . and . returnValue ( steps ) ;
1038
1028
1039
1029
stepperService . activeStep = steps [ 0 ] ;
@@ -1044,13 +1034,10 @@ describe('Stepper service unit tests', () => {
1044
1034
stepperService . expandThroughApi ( steps [ 1 ] ) ;
1045
1035
1046
1036
expect ( stepperService . activeStep ) . toBe ( steps [ 1 ] ) ;
1047
- expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1048
- expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledWith ( false ) ;
1049
- expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1050
- expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledWith ( true ) ;
1037
+ expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledOnceWith ( false ) ;
1038
+ expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledOnceWith ( true ) ;
1051
1039
1052
1040
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Vertical ) ;
1053
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Vertical ) ;
1054
1041
stepperService . expandThroughApi ( steps [ 0 ] ) ;
1055
1042
1056
1043
expect ( stepperService . activeStep ) . toBe ( steps [ 0 ] ) ;
@@ -1070,7 +1057,6 @@ describe('Stepper service unit tests', () => {
1070
1057
1071
1058
it ( 'should collapse the currently active step and fire the change event' , ( ) => {
1072
1059
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Horizontal ) ;
1073
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Horizontal ) ;
1074
1060
spyOnProperty ( stepper , 'steps' , 'get' ) . and . returnValue ( steps ) ;
1075
1061
1076
1062
stepperService . previousActiveStep = steps [ 0 ] ;
@@ -1088,12 +1074,10 @@ describe('Stepper service unit tests', () => {
1088
1074
expect ( stepperService . collapsingSteps ) . not . toContain ( steps [ 0 ] ) ;
1089
1075
expect ( stepperService . activeStep ) . not . toBe ( steps [ 0 ] ) ;
1090
1076
expect ( stepperService . activeStep ) . toBe ( steps [ 1 ] ) ;
1091
- expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1092
- expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledWith ( false ) ;
1077
+ expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledOnceWith ( false ) ;
1093
1078
expect ( steps [ 1 ] . activeChange . emit ) . not . toHaveBeenCalled ( ) ;
1094
1079
1095
1080
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Vertical ) ;
1096
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Vertical ) ;
1097
1081
1098
1082
stepperService . previousActiveStep = steps [ 1 ] ;
1099
1083
stepperService . activeStep = steps [ 0 ] ;
@@ -1108,8 +1092,7 @@ describe('Stepper service unit tests', () => {
1108
1092
expect ( stepperService . activeStep ) . not . toBe ( steps [ 1 ] ) ;
1109
1093
expect ( stepperService . activeStep ) . toBe ( steps [ 0 ] ) ;
1110
1094
1111
- expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1112
- expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledWith ( false ) ;
1095
+ expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledOnceWith ( false ) ;
1113
1096
expect ( steps [ 0 ] . activeChange . emit ) . not . toHaveBeenCalledTimes ( 2 ) ;
1114
1097
1115
1098
const testValues = [ null , undefined , [ ] , { } , 'sampleString' ] ;
@@ -1146,7 +1129,6 @@ describe('Stepper service unit tests', () => {
1146
1129
1147
1130
it ( 'should determine the steps that should be disabled in linear mode based on the validity of the active step' , ( ) => {
1148
1131
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Horizontal ) ;
1149
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Horizontal ) ;
1150
1132
spyOnProperty ( stepper , 'steps' ) . and . returnValue ( steps ) ;
1151
1133
1152
1134
for ( const step of steps ) {
@@ -1192,7 +1174,6 @@ describe('Stepper service unit tests', () => {
1192
1174
1193
1175
it ( 'should emit activating event' , ( ) => {
1194
1176
spyOnProperty ( stepper , 'orientation' , 'get' ) . and . returnValue ( IgxStepperOrientation . Horizontal ) ;
1195
- expect ( stepper . orientation ) . toBe ( IgxStepperOrientation . Horizontal ) ;
1196
1177
spyOnProperty ( stepper , 'steps' ) . and . returnValue ( steps ) ;
1197
1178
const activeChangingSpy = spyOn ( stepper . activeStepChanging , 'emit' ) ;
1198
1179
stepperService . activeStep = steps [ 0 ] ;
0 commit comments