File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ describe('useWizard', () => {
161161 expect ( result . current . isLastStep ) . toBe ( false ) ;
162162 } ) ;
163163
164- test ( 'should thrown error on nextStep' , async ( ) => {
164+ test ( 'should thrown error on async nextStep' , async ( ) => {
165165 const { result } = renderUseWizardHook ( ) ;
166166
167167 act ( ( ) => {
@@ -177,4 +177,23 @@ describe('useWizard', () => {
177177 } ) ;
178178 } ) ;
179179 } ) ;
180+
181+ test ( 'should thrown error on sync nextStep' , async ( ) => {
182+ const { result } = renderUseWizardHook ( ) ;
183+
184+ act ( ( ) => {
185+ result . current . handleStep ( ( ) => {
186+ throw Error ( 'Sync gotcha' ) ;
187+ } ) ;
188+
189+ try {
190+ result . current . nextStep ( ) ;
191+ } catch ( error ) {
192+ expect ( error ) . toEqual ( Error ( 'Sync gotcha' ) ) ;
193+ expect ( error ) . toEqual ( Error ( 'Sync gotcha' ) ) ;
194+ expect ( result . current . activeStep ) . toBe ( 0 ) ;
195+ expect ( result . current . isFirstStep ) . toBe ( true ) ;
196+ }
197+ } ) ;
198+ } ) ;
180199} ) ;
You can’t perform that action at this time.
0 commit comments