Anyone know how to properly simulate filling form inputs, then submit the form and checking that the onValidSubmit method has been properly called with the expected values, using jest and enzyme ?
Have been digging in the code for half a day, but couldn't figure this on. Here's a test I'd expect to work:
I understand that enzyme simulate("change") (doc) method will call the element's related onChange method, which Formsy implements. Since formsy onChange expects 2 variables currentValues and isChanged, I passed them to the simulate method.
If overriding the onChange method in my component, I can see that the function is properly called. That confirms the fact that my simulate call is done properly.
Yet, my doSubmit method never gets called on onValidSubmit (or onSubmit for that matter). When debugging my elements, the inputs values stay undefined, hence they never got updated.
Anyone know how to properly simulate filling form inputs, then submit the form and checking that the onValidSubmit method has been properly called with the expected values, using jest and enzyme ?
Have been digging in the code for half a day, but couldn't figure this on. Here's a test I'd expect to work:
Using a regular formsy form behind:
I understand that enzyme
simulate("change")
(doc) method will call the element's related onChange method, which Formsy implements. Since formsy onChange expects 2 variables currentValues and isChanged, I passed them to the simulate method. If overriding the onChange method in my component, I can see that the function is properly called. That confirms the fact that my simulate call is done properly.Yet, my doSubmit method never gets called on onValidSubmit (or onSubmit for that matter). When debugging my elements, the inputs values stay undefined, hence they never got updated.
Any help will really be appreciated Cordially