@@ -1009,7 +1009,39 @@ describe('<Formik>', () => {
1009
1009
setSubmitting : expect . any ( Function ) ,
1010
1010
setTouched : expect . any ( Function ) ,
1011
1011
setValues : expect . any ( Function ) ,
1012
- } )
1012
+ } ) ,
1013
+ InitialValues
1014
+ ) ;
1015
+ } ) ;
1016
+
1017
+ it ( 'should call onReset with values and actions and new initial values when form is reset with values' , ( ) => {
1018
+ const onReset = jest . fn ( ) ;
1019
+ const { getProps } = renderFormik ( {
1020
+ initialValues : InitialValues ,
1021
+ onSubmit : noop ,
1022
+ onReset,
1023
+ } ) ;
1024
+
1025
+ const newInitialValues = { name : 'jared' , age : 31 , }
1026
+
1027
+ act ( ( ) => {
1028
+ getProps ( ) . resetForm ( { values : newInitialValues } ) ;
1029
+ } ) ;
1030
+
1031
+ expect ( onReset ) . toHaveBeenCalledWith (
1032
+ InitialValues ,
1033
+ expect . objectContaining ( {
1034
+ resetForm : expect . any ( Function ) ,
1035
+ setErrors : expect . any ( Function ) ,
1036
+ setFieldError : expect . any ( Function ) ,
1037
+ setFieldTouched : expect . any ( Function ) ,
1038
+ setFieldValue : expect . any ( Function ) ,
1039
+ setStatus : expect . any ( Function ) ,
1040
+ setSubmitting : expect . any ( Function ) ,
1041
+ setTouched : expect . any ( Function ) ,
1042
+ setValues : expect . any ( Function ) ,
1043
+ } ) ,
1044
+ newInitialValues
1013
1045
) ;
1014
1046
} ) ;
1015
1047
0 commit comments