title: How to test function and inner statement after form submit handler in jest/enzyme react
body: <p>I am working with React functional component which has a form. I have created a form handler which triggers <code>onSuccess</code> and <code>onFailure</code>, <code>onSuccess</code> function closes the model.</p>
  
  <p>Now <strong>I need to write a test</strong> for <code>onFailure</code>, <code>onSuccess</code> functions and for the modal closing statement.</p>
  
  <p>Component's code is:</p>
  
  <pre class="lang-js prettyprint-override"><code>export const TestUpdateModal = function( props ) {
  
    const onSuccess = () =&gt; {
      MiModal.close( 'AccUpdate' );
    }
  
    const onFailure = ( message ) =&gt; {
      // show error message
    }
  
    const { handleSubmit } = updateFormHandler({
      onSuccess: onSuccess,
      onFailure: onFailure
    });
  
    return &lt;form onSubmit={ e =&gt; handleSubmit( e ) }/&gt;
  }  
  
  ----------------------------
  
  updateFormHandler is
  
      import { useMutation } from '@apollo/react-hooks';
      import UpdateProfile_MUTATION from '../../../graphql/mutations/updateProfile/updateProfile';
  
      export const updateFormHandler = ( { onSuccess, onFailure } ) =&gt; {
  
      const onCompleted =  response =&gt; {
        const {
          UpdateProfile: {
            meta: {
              status
            },
            messages
          }
        } = response;
  
        const isSuccess = status === 'success';
  
        if( isSuccess ){
          onSuccess();
        }
        else {
          onFailure( {
            type: 'error',
            messages: messages
          } );
        }
      }
  
      const onError = ( response ) =&gt; {
  
        const { message } = response;
        message &amp;&amp;
        onFailure( {
          type: 'error',
          messages: [{
            description: response.message
          }]
        } );
      }
  
      const [updateProfile] = useMutation( UpdateProfile_MUTATION, {
        onCompleted: onCompleted,
        onError: onError
      } );
  
      const handleSubmit = ( e, digitalId, version ) =&gt; {
        e.preventDefault();
  
        updateProfile( {
          variables: {
            emailAddress: e.target.emailId.value,
            password: e.target.newPasswordId.value,
            firstName: e.target.firstName.value,
            lastName: e.target.lastName.value,
            dateOfBirth: e.target.birthday?.value,
            version: version,
            digitalId: digitalId
          }
        } );
  
      }
  
      return {
        handleSubmit
      };
  
      }
  
  </code></pre>