@@ -3,6 +3,7 @@ import { mount } from 'enzyme';
3
3
import toJSon from 'enzyme-to-json' ;
4
4
5
5
import FormRenderer , { componentTypes , validatorTypes } from '@data-driven-forms/react-form-renderer' ;
6
+ import * as enterHandle from '@data-driven-forms/common/src/wizard/enter-handler' ;
6
7
7
8
import { formFieldsMapper , layoutMapper } from '../../index' ;
8
9
import Wizard from '../../form-fields/wizard/wizard' ;
@@ -149,6 +150,33 @@ describe('<Wizard />', () => {
149
150
expect ( toJSon ( wrapper ) ) . toMatchSnapshot ( ) ;
150
151
} ) ;
151
152
153
+ it . only ( 'should call enter handler when pressing enter' , ( ) => {
154
+ enterHandle . default = jest . fn ( ) ;
155
+
156
+ const wrapper = mount ( < Wizard { ...initialProps } /> ) ;
157
+
158
+ expect ( enterHandle . default ) . not . toHaveBeenCalled ( ) ;
159
+
160
+ const wizard = wrapper . find ( '.pf-c-wizard' ) ;
161
+
162
+ const event = { someEvent : true } ;
163
+ const formOptions = expect . any ( Object ) ;
164
+ const handleNext = expect . any ( Function ) ;
165
+ const handleSubmit = expect . any ( Function ) ;
166
+ const findCurrentStep = expect . any ( Function ) ;
167
+
168
+ wizard . props ( ) . onKeyDown ( event ) ;
169
+
170
+ expect ( enterHandle . default ) . toHaveBeenCalledWith (
171
+ event ,
172
+ formOptions ,
173
+ '1' ,
174
+ findCurrentStep ,
175
+ handleNext ,
176
+ handleSubmit
177
+ ) ;
178
+ } ) ;
179
+
152
180
it ( 'should render correctly in modal and unmount' , ( ) => {
153
181
const wrapper = mount ( < Wizard inModal { ...initialProps } /> ) ;
154
182
expect ( toJSon ( wrapper ) ) . toMatchSnapshot ( ) ;
0 commit comments