@@ -116,14 +116,13 @@ describe('Form', () => {
116116 } ) ;
117117 } ) ;
118118
119- describe ( 'custom beforeSubmit error' , ( ) => {
120- let beforeSubmit : Mock ;
119+ describe ( 'custom onBeforeSubmit error' , ( ) => {
120+ let onBeforeSubmit : Mock ;
121121
122122 beforeEach ( ( ) => {
123- beforeSubmit = vi . fn ( ) ;
123+ onBeforeSubmit = vi . fn ( ) ;
124124 render (
125125 < Form
126- beforeSubmit = { beforeSubmit }
127126 content = { {
128127 value : {
129128 kind : 'number' ,
@@ -135,6 +134,7 @@ describe('Form', () => {
135134 validationSchema = { z . object ( {
136135 value : z . number ( { message : 'Please enter a number' } )
137136 } ) }
137+ onBeforeSubmit = { onBeforeSubmit }
138138 onError = { onError }
139139 onSubmit = { onSubmit }
140140 />
@@ -156,12 +156,12 @@ describe('Form', () => {
156156 'Please enter a number'
157157 ] )
158158 ) ;
159- expect ( beforeSubmit ) . not . toHaveBeenCalled ( ) ;
159+ expect ( onBeforeSubmit ) . not . toHaveBeenCalled ( ) ;
160160 expect ( onSubmit ) . not . toHaveBeenCalled ( ) ;
161161 } ) ;
162162
163- it ( 'should not allow submitting the form with the beforeSubmit error' , async ( ) => {
164- beforeSubmit . mockResolvedValueOnce ( { errorMessage : 'Invalid!' , success : false } ) ;
163+ it ( 'should not allow submitting the form with the onBeforeSubmit error' , async ( ) => {
164+ onBeforeSubmit . mockResolvedValueOnce ( { errorMessage : 'Invalid!' , success : false } ) ;
165165 const field : HTMLInputElement = screen . getByLabelText ( 'Value' ) ;
166166 await userEvent . type ( field , '-1' ) ;
167167 fireEvent . submit ( screen . getByTestId ( testid ) ) ;
@@ -171,8 +171,8 @@ describe('Form', () => {
171171 expect ( onSubmit ) . not . toHaveBeenCalled ( ) ;
172172 } ) ;
173173
174- it ( 'should allow submitting the form if beforeSubmit returns true' , async ( ) => {
175- beforeSubmit . mockResolvedValueOnce ( { success : true } ) ;
174+ it ( 'should allow submitting the form if onBeforeSubmit returns true' , async ( ) => {
175+ onBeforeSubmit . mockResolvedValueOnce ( { success : true } ) ;
176176 const field : HTMLInputElement = screen . getByLabelText ( 'Value' ) ;
177177 await userEvent . type ( field , '-1' ) ;
178178 fireEvent . submit ( screen . getByTestId ( testid ) ) ;
0 commit comments