Skip to content

Commit 1542727

Browse files
committed
Add missing test for PF4 wizard
1 parent 0167d7f commit 1542727

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/pf4-component-mapper/src/tests/wizard/wizard.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { mount } from 'enzyme';
33
import toJSon from 'enzyme-to-json';
44

55
import FormRenderer, { componentTypes, validatorTypes } from '@data-driven-forms/react-form-renderer';
6+
import * as enterHandle from '@data-driven-forms/common/src/wizard/enter-handler';
67

78
import { formFieldsMapper, layoutMapper } from '../../index';
89
import Wizard from '../../form-fields/wizard/wizard';
@@ -149,6 +150,33 @@ describe('<Wizard />', () => {
149150
expect(toJSon(wrapper)).toMatchSnapshot();
150151
});
151152

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+
152180
it('should render correctly in modal and unmount', () => {
153181
const wrapper = mount(<Wizard inModal { ...initialProps } />);
154182
expect(toJSon(wrapper)).toMatchSnapshot();

0 commit comments

Comments
 (0)