@@ -158,13 +158,15 @@ describe('useWizard', () => {
158158 test ( 'should not go to given step index when out of boundary' , async ( ) => {
159159 const { result } = renderUseWizardHook ( ) ;
160160
161- act ( ( ) => {
162- result . current . goToStep ( 2 ) ;
163- } ) ;
164-
165- expect ( result . current . activeStep ) . toBe ( 0 ) ;
166- expect ( result . current . isFirstStep ) . toBe ( true ) ;
167- expect ( result . current . isLastStep ) . toBe ( false ) ;
161+ try {
162+ act ( ( ) => {
163+ result . current . goToStep ( 2 ) ;
164+ } ) ;
165+ } catch ( error ) {
166+ expect ( result . current . activeStep ) . toBe ( 0 ) ;
167+ expect ( result . current . isFirstStep ) . toBe ( true ) ;
168+ expect ( result . current . isLastStep ) . toBe ( false ) ;
169+ }
168170 } ) ;
169171
170172 test ( 'should thrown error on async nextStep' , async ( ) => {
@@ -185,16 +187,18 @@ describe('useWizard', () => {
185187 await waitForNextUpdate ( ) ;
186188 } ) ;
187189
188- test ( 'should thrown error on sync nextStep' , ( ) => {
190+ test ( 'should throw error on sync nextStep' , async ( ) => {
189191 const { result } = renderUseWizardHook ( ) ;
190192
191193 act ( ( ) => {
192194 result . current . handleStep ( ( ) => {
193195 throw Error ( 'Sync gotcha' ) ;
194196 } ) ;
197+ } ) ;
195198
199+ await act ( async ( ) => {
196200 try {
197- result . current . nextStep ( ) ;
201+ await result . current . nextStep ( ) ;
198202 } catch ( error ) {
199203 expect ( error ) . toEqual ( Error ( 'Sync gotcha' ) ) ;
200204 expect ( result . current . activeStep ) . toBe ( 0 ) ;
0 commit comments