我正在尝试使用jest模拟redux形式的提交按钮。我尝试了以下方法。
const tempWrapper = shallow(
<Provider store={store}>
<SignInForm onSubmit={mockButtonSubmit} />
</Provider>,
).dive();
tempWrapper.prop('onSubmit') === mockButtonSubmit;
expect(mockButtonSubmit).toBeCalledWith();
但是它返回了以下错误
expect(jest.fn()).toBeCalledWith(expected)
Expected mock function to have been called with:
[]
But it was not called.
当我调试时,我会像下面这样
<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]} />
由于我是新手,所以我想知道我所采用的方法是否正确