@@ -203,40 +203,16 @@ describe('Rendering Tests', () => {
203
203
owner : stepper ,
204
204
} ;
205
205
206
- stepper . navigateTo ( null ) ;
207
- fix . detectChanges ( ) ;
208
- expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
209
- expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
210
- expect ( serviceExpandSpy ) . not . toHaveBeenCalled ( ) ;
211
- expect ( serviceCollapseSpy ) . not . toHaveBeenCalled ( ) ;
212
-
213
- stepper . navigateTo ( undefined ) ;
214
- fix . detectChanges ( ) ;
215
- expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
216
- expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
217
- expect ( serviceExpandSpy ) . not . toHaveBeenCalled ( ) ;
218
- expect ( serviceCollapseSpy ) . not . toHaveBeenCalled ( ) ;
219
-
220
- stepper . navigateTo ( [ ] as any ) ;
221
- fix . detectChanges ( ) ;
222
- expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
223
- expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
224
- expect ( serviceExpandSpy ) . not . toHaveBeenCalled ( ) ;
225
- expect ( serviceCollapseSpy ) . not . toHaveBeenCalled ( ) ;
226
-
227
- stepper . navigateTo ( { } as any ) ;
228
- fix . detectChanges ( ) ;
229
- expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
230
- expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
231
- expect ( serviceExpandSpy ) . not . toHaveBeenCalled ( ) ;
232
- expect ( serviceCollapseSpy ) . not . toHaveBeenCalled ( ) ;
206
+ const testValues = [ null , undefined , [ ] , { } , 'sampleString' ] ;
233
207
234
- stepper . navigateTo ( 'sampleString' as any ) ;
235
- fix . detectChanges ( ) ;
236
- expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
237
- expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
238
- expect ( serviceExpandSpy ) . not . toHaveBeenCalled ( ) ;
239
- expect ( serviceCollapseSpy ) . not . toHaveBeenCalled ( ) ;
208
+ for ( const val of testValues ) {
209
+ stepper . navigateTo ( val as any ) ;
210
+ fix . detectChanges ( ) ;
211
+ expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
212
+ expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
213
+ expect ( serviceExpandSpy ) . not . toHaveBeenCalled ( ) ;
214
+ expect ( serviceCollapseSpy ) . not . toHaveBeenCalled ( ) ;
215
+ }
240
216
241
217
stepper . navigateTo ( 1 ) ;
242
218
fix . detectChanges ( ) ;
@@ -548,6 +524,16 @@ describe('Rendering Tests', () => {
548
524
549
525
expect ( stepper . animationDuration ) . toBe ( 1000 ) ;
550
526
527
+ fix . componentInstance . animationDuration = null ;
528
+ fix . detectChanges ( ) ;
529
+
530
+ expect ( stepper . animationDuration ) . toBe ( ( stepper as any ) . _defaultAnimationDuration ) ;
531
+
532
+ fix . componentInstance . animationDuration = undefined ;
533
+ fix . detectChanges ( ) ;
534
+
535
+ expect ( stepper . animationDuration ) . toBe ( ( stepper as any ) . _defaultAnimationDuration ) ;
536
+
551
537
expect ( stepper . horizontalAnimationType ) . toBe ( fix . componentInstance . horizontalAnimationType ) ;
552
538
expect ( stepper . horizontalAnimationType ) . toBe ( 'slide' ) ;
553
539
@@ -643,7 +629,7 @@ describe('Rendering Tests', () => {
643
629
fix . detectChanges ( ) ;
644
630
645
631
// if the dynamically added step's position is after the active step in linear mode,
646
- // and this step is not valid, the added step should be linear disabled
632
+ // and the latter is not valid, the added step should be linear disabled
647
633
stepper . steps [ 0 ] . isValid = true ;
648
634
stepper . steps [ 1 ] . isValid = false ;
649
635
stepper . steps [ 1 ] . active = true ;
@@ -1022,6 +1008,14 @@ describe('Stepper service unit tests', () => {
1022
1008
expect ( stepperService . activeStep ) . toBe ( steps [ 0 ] ) ;
1023
1009
expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1024
1010
expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledWith ( true ) ;
1011
+
1012
+ const testValues = [ null , undefined , [ ] , { } , 'sampleString' ] ;
1013
+
1014
+ for ( const val of testValues ) {
1015
+ expect ( ( ) => {
1016
+ stepperService . expand ( val as any ) ;
1017
+ } ) . toThrow ( ) ;
1018
+ }
1025
1019
} ) ;
1026
1020
1027
1021
it ( 'should expand a step through API by activating it and firing the step\'s activeChange event' , ( ) => {
@@ -1037,7 +1031,6 @@ describe('Stepper service unit tests', () => {
1037
1031
stepperService . expandThroughApi ( steps [ 1 ] ) ;
1038
1032
1039
1033
expect ( stepperService . activeStep ) . toBe ( steps [ 1 ] ) ;
1040
-
1041
1034
expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1042
1035
expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledWith ( false ) ;
1043
1036
expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -1052,6 +1045,14 @@ describe('Stepper service unit tests', () => {
1052
1045
expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledWith ( false ) ;
1053
1046
expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 2 ) ;
1054
1047
expect ( steps [ 0 ] . activeChange . emit ) . toHaveBeenCalledWith ( true ) ;
1048
+
1049
+ const testValues = [ null , undefined , [ ] , { } , 'sampleString' ] ;
1050
+
1051
+ for ( const val of testValues ) {
1052
+ expect ( ( ) => {
1053
+ stepperService . expandThroughApi ( val as any ) ;
1054
+ } ) . toThrow ( ) ;
1055
+ }
1055
1056
} ) ;
1056
1057
1057
1058
it ( 'should collapse the currently active step and fire the change event' , ( ) => {
@@ -1097,6 +1098,14 @@ describe('Stepper service unit tests', () => {
1097
1098
expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1098
1099
expect ( steps [ 1 ] . activeChange . emit ) . toHaveBeenCalledWith ( false ) ;
1099
1100
expect ( steps [ 0 ] . activeChange . emit ) . not . toHaveBeenCalledTimes ( 2 ) ;
1101
+
1102
+ const testValues = [ null , undefined , [ ] , { } , 'sampleString' ] ;
1103
+
1104
+ for ( const val of testValues ) {
1105
+ expect ( ( ) => {
1106
+ stepperService . collapse ( val as any ) ;
1107
+ } ) . toThrow ( ) ;
1108
+ }
1100
1109
} ) ;
1101
1110
1102
1111
it ( 'should determine the steps that are marked as visited based on the active step' , ( ) => {
@@ -1137,7 +1146,7 @@ describe('Stepper service unit tests', () => {
1137
1146
expect ( stepperService . linearDisabledSteps . size ) . toBe ( 0 ) ;
1138
1147
stepperService . calculateLinearDisabledSteps ( ) ;
1139
1148
expect ( stepperService . linearDisabledSteps . size ) . toBe ( 3 ) ;
1140
- let sampleSet : Set < IgxStepComponent > = new Set < IgxStepComponent > ( [ steps [ 1 ] , steps [ 2 ] , steps [ 3 ] ] ) ;
1149
+ let sampleSet = new Set < IgxStepComponent > ( [ steps [ 1 ] , steps [ 2 ] , steps [ 3 ] ] ) ;
1141
1150
expect ( stepperService . linearDisabledSteps ) . toEqual ( sampleSet ) ;
1142
1151
1143
1152
spyOnProperty ( steps [ 0 ] , 'isValid' ) . and . returnValue ( true ) ;
0 commit comments