You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anyone know how to properly simulate filling form inputs, then submit the form and checking that the onValidSubmit method has been properly called with the expected values, using jest and enzyme ?
Have been digging in the code for half a day, but couldn't figure this on. Here's a test I'd expect to work:
describe("EmailLoginForm",()=>{constmockStore=configureStore();constinitialState={firebase: {login: jest.fn((email,password)=>Promise.resolve()),},};constinitialContext={store: mockStore(),};// dive in Formsyconstwrapper=shallow(<EmailLoginForm{...initialState}/>,{context: initialContext,}).dive();it("should render properly",()=>{expect(wrapper).toMatchSnapshot();});it("can trigger a login action",()=>{constform=wrapper.find("Formsy");form.simulate("change",{email: "a@a.com",password: "password"},true);form.find(".submit-btn").simulate("click");expect(initialState.firebase.login).toHaveBeenCalledWith("a@a.com","password",);});
I understand that enzyme simulate("change") (doc) method will call the element's related onChange method, which Formsy implements. Since formsy onChange expects 2 variables currentValues and isChanged, I passed them to the simulate method.
If overriding the onChange method in my component, I can see that the function is properly called. That confirms the fact that my simulate call is done properly.
Yet, my doSubmit method never gets called on onValidSubmit (or onSubmit for that matter). When debugging my elements, the inputs values stay undefined, hence they never got updated.
Any help will really be appreciated
Cordially
The text was updated successfully, but these errors were encountered:
Anyone know how to properly simulate filling form inputs, then submit the form and checking that the onValidSubmit method has been properly called with the expected values, using jest and enzyme ?
Have been digging in the code for half a day, but couldn't figure this on. Here's a test I'd expect to work:
Using a regular formsy form behind:
I understand that enzyme
simulate("change")
(doc) method will call the element's related onChange method, which Formsy implements. Since formsy onChange expects 2 variables currentValues and isChanged, I passed them to the simulate method.If overriding the onChange method in my component, I can see that the function is properly called. That confirms the fact that my simulate call is done properly.
Yet, my doSubmit method never gets called on onValidSubmit (or onSubmit for that matter). When debugging my elements, the inputs values stay undefined, hence they never got updated.
Any help will really be appreciated
Cordially
The text was updated successfully, but these errors were encountered: