diff --git a/packages/core/src/useForm/useForm.spec.ts b/packages/core/src/useForm/useForm.spec.ts index 882677f0..2c066418 100644 --- a/packages/core/src/useForm/useForm.spec.ts +++ b/packages/core/src/useForm/useForm.spec.ts @@ -565,6 +565,23 @@ describe('form submit', () => { await flush(); expect(formData.get('foo')).toBe('bar'); }); + + test('can compute the submit counts, attempts and resets', async () => { + const { submitAttemptsCount, handleSubmit, reset } = await renderSetup(() => { + return useForm({ initialValues: { foo: 'bar' } }); + }); + + const cb = vi.fn(); + const onSubmit = handleSubmit(v => cb(v.toObject())); + + expect(submitAttemptsCount.value).toBe(0); + onSubmit(new Event('submit')); + expect(submitAttemptsCount.value).toBe(1); + onSubmit(new Event('submit')); + expect(submitAttemptsCount.value).toBe(2); + await reset(); + expect(submitAttemptsCount.value).toBe(0); + }); }); describe('form dirty state', () => { diff --git a/packages/core/src/useForm/useFormActions.ts b/packages/core/src/useForm/useFormActions.ts index 1aa9c743..e2d34eab 100644 --- a/packages/core/src/useForm/useFormActions.ts +++ b/packages/core/src/useForm/useFormActions.ts @@ -146,6 +146,8 @@ export function useFormActions