I have a method that receives some values as a parameter and then dispatches an action. The problem is that when I shallow my component to test this method, I have an error saying that dispatch is not a function.
TEST:
test('it changes the state when submit is clicked', () => {
const wrapper = shallow(<WizardForm store={store}/>);
const values = {
entrySign: 'archivoSign',
signCertificateFile: 'file',
signCertificate: 'text',
entryAuth: 'notArchivoAuth',
authCertificateFile: 'file',
authCertificate: 'text'
}
const form = wrapper.instance();
//in this method I get the error
form.submit(values)
METHOD:
submit(values) {
var authCertificate = this.checkAuth(values);
var signCertificate = this.checkSign(values);
let req = {
authCertificate: authCertificate,
signCertificate: signCertificate,
userId: this.state.userId
}
const { dispatch } = this.props
dispatch({type: 'CERTIFICATES_FETCH_REQUESTED', payload: {req}})
}
Can anyone help me? I do not know what I am doing wrong. Thanks in advance!
Okay so now I have this test:
The problem now I get is: ReferenceError: submit is not defined Any suggestions @RIYAJ KHAN ?