Skip to content

Commit 83863f8

Browse files
author
Alban Depretz
committed
fix: Call submitForm instead
1 parent e182c98 commit 83863f8

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/__tests__/withNextInputAutoFocus.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { mount } from "enzyme";
66

77
import { withNextInputAutoFocusForm, withNextInputAutoFocusInput } from "../..";
88

9-
const handleSubmit = jest.fn();
9+
const submitForm = jest.fn();
1010
const withFormikMock = withContext({ formik: PropTypes.object }, () => ({
1111
formik: {
12-
handleSubmit
12+
submitForm
1313
}
1414
}));
1515

@@ -55,7 +55,7 @@ describe("withNextInputAutoFocus", () => {
5555
expect(focusInput).toHaveBeenCalledWith("last");
5656
lastInput.props().onSubmitEditing();
5757
expect(focusInput).not.toHaveBeenCalledTimes(3);
58-
expect(handleSubmit).toHaveBeenCalled();
58+
expect(submitForm).toHaveBeenCalled();
5959
});
6060

6161
it("does not erase passed input props", () => {
@@ -70,7 +70,7 @@ describe("withNextInputAutoFocus", () => {
7070

7171
expect(input.props().returnKeyType).toEqual("correct value");
7272
input.props().onSubmitEditing();
73-
expect(handleSubmit).toHaveBeenCalled();
73+
expect(submitForm).toHaveBeenCalled();
7474
expect(onSubmitEditing).toHaveBeenCalled();
7575
});
7676
});

src/withNextInputAutoFocus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const withNextInputAutoFocusForm = WrappedComponent => {
3838
const isLastInput = inputPosition === this.inputs.length - 1;
3939

4040
if (isLastInput) {
41-
this.context.formik.handleSubmit();
41+
this.context.formik.submitForm();
4242
} else {
4343
const nextInput = this.inputs[inputPosition + 1];
4444
this.inputRefs[nextInput.props.name].focus();

0 commit comments

Comments
 (0)