File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ const Wizard: React.FC<WizardProps> = React.memo(
3333 stepIndex > 0 &&
3434 stepIndex < React . Children . toArray ( children ) . length
3535 ) {
36+ setActiveStep ( stepIndex ) ;
37+ } else {
3638 if ( __DEV__ ) {
3739 logger . log (
3840 'warn' ,
@@ -42,7 +44,6 @@ const Wizard: React.FC<WizardProps> = React.memo(
4244 ] . join ( '' ) ,
4345 ) ;
4446 }
45- setActiveStep ( stepIndex ) ;
4647 }
4748 } ) ;
4849
Original file line number Diff line number Diff line change @@ -122,6 +122,21 @@ describe('useWizard', () => {
122122 expect ( result . current . isLastStep ) . toBe ( true ) ;
123123 } ) ;
124124
125+ test ( 'should go to given step index and not invoke `handleStep` handler' , async ( ) => {
126+ const handler = jest . fn ( ) ;
127+ const { result } = renderUseWizardHook ( ) ;
128+
129+ act ( ( ) => {
130+ result . current . handleStep ( handler ) ;
131+ result . current . goToStep ( 1 ) ;
132+ } ) ;
133+
134+ expect ( handler ) . not . toBeCalled ( ) ;
135+ expect ( result . current . activeStep ) . toBe ( 1 ) ;
136+ expect ( result . current . isFirstStep ) . toBe ( false ) ;
137+ expect ( result . current . isLastStep ) . toBe ( true ) ;
138+ } ) ;
139+
125140 test ( 'should not go to given step index when out of boundary' , async ( ) => {
126141 const { result } = renderUseWizardHook ( ) ;
127142
You can’t perform that action at this time.
0 commit comments