I have started migrating from redux-form to react-final-form to make my bundle smaller. I had couple of tests for my forms and one of them was to test that the correct action was called on form submit. Store action in my test never gets called after switching to react-final-form.
Is there a way ho to test submit function when form is passed as a property.
My test:
it('submits the form', () => {
const wrapper = shallowUntilTarget(<LoginFormContainer store={store} />, 'form');
wrapper.find('form').simulate('submit');
expect(store.getActions()).toEqual(expect.arrayContaining([{ formObj: {}, type: 'PATIENT_LOGIN_REQUEST' }]));
});
shallowUntilTarget renders the actual form through container
Tested component:
class LoginForm extends React.Component<Props> {
submitForm = (values) => {
this.props.dispatch(actions.loginPatient(values));
};
render() {
return (
<Form
onSubmit={this.submitForm}
render={({ handleSubmit }) => (
<form onSubmit={handleSubmit} />
mount. - Blackthis.submitForm()is not getting called at all? And that way of simulating the submit works in Redux Form? - Erik R.