0

I am trying to simulate the submit button in redux form using jest.I have tried the below approach.

const tempWrapper = shallow(
      <Provider store={store}>
        <SignInForm onSubmit={mockButtonSubmit} />
      </Provider>,
    ).dive();

    tempWrapper.prop('onSubmit') === mockButtonSubmit;
   expect(mockButtonSubmit).toBeCalledWith();

But it returns me the following error

expect(jest.fn()).toBeCalledWith(expected)

    Expected mock function to have been called with:
      []
    But it was not called.

When i debug i am getting like below

<ReduxForm onSubmit={[Function: mockConstructor]} touchOnBlur={true} touchOnChange={false} persistentSubmitErrors={false} destroyOnUnmount={true} shouldAsyncValidate={[Function: defaultShouldAsyncValidate]} shouldValidate={[Function: defaultShouldValidate]} shouldError={[Function: defaultShouldError]} shouldWarn={[Function: defaultShouldWarn]} enableReinitialize={false} keepDirtyOnReinitialize={false} updateUnregisteredFields={false} getFormState={[Function: getFormState]} pure={true} forceUnregisterOnUnmount={false} submitAsSideEffect={false} form="signIn" validate={[Function: validate]} />

Since i am new to jest i would like to know whether the approach i have done is correct or not

brass monkey
  • 5,841
  • 10
  • 36
  • 61
Nidhin Kumar
  • 3,278
  • 9
  • 40
  • 72

0 Answers0