File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const Wizard: React.FC<WizardProps> = React.memo(
3030
3131 const goToStep = React . useRef ( ( stepIndex : number ) => {
3232 if (
33- stepIndex > 0 &&
33+ stepIndex >= 0 &&
3434 stepIndex < React . Children . toArray ( children ) . length
3535 ) {
3636 setActiveStep ( stepIndex ) ;
Original file line number Diff line number Diff line change @@ -122,6 +122,18 @@ describe('useWizard', () => {
122122 expect ( result . current . isLastStep ) . toBe ( true ) ;
123123 } ) ;
124124
125+ test ( 'should go to given step index' , async ( ) => {
126+ const { result } = renderUseWizardHook ( 1 ) ;
127+
128+ act ( ( ) => {
129+ result . current . goToStep ( 0 ) ;
130+ } ) ;
131+
132+ expect ( result . current . activeStep ) . toBe ( 0 ) ;
133+ expect ( result . current . isFirstStep ) . toBe ( true ) ;
134+ expect ( result . current . isLastStep ) . toBe ( false ) ;
135+ } ) ;
136+
125137 test ( 'should go to given step index and not invoke `handleStep` handler' , async ( ) => {
126138 const handler = jest . fn ( ) ;
127139 const { result } = renderUseWizardHook ( ) ;
You can’t perform that action at this time.
0 commit comments