I have a component where I use redux form to which I pass redux form props like this:
export const UttakInfoPanel = ({
submitValidation,
...formProps
})
I am passing a submitValidation
function to a redux form handleSubmit
function like this:
<form onSubmit={formProps.handleSubmit(submitValidation)}>
Submit validation works fine. I have also made a test for that component:
it('will show InfoPanel', () => {
const formProps = {
handleSubmit: sinon.spy,
error: {},
};
const wrapper = shallowWithIntl(<InfoPanel
submitValidation={sinon.spy()}
formProps={formProps}
/>);
});
But, when I am running my test I get:
TypeError: formProps.handleSubmit is not a function
Why am I getting this error, when also on the inspecting the formProps
in the console I can see that handleSubmit
is a function. How can I make this test pass?
如果您使用rest运算符,则最后一个参数将具有Array类型,请尝试从UttakInfoPanel组件中删除散布。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.