Skip to content

Commit 23458a9

Browse files
authored
Merge pull request #270 from rvsia/formApiWizardPF4
fix(pf4): send formOptions as second argument in wizard
2 parents d193e4d + ed7bf61 commit 23458a9

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

packages/pf4-component-mapper/src/form-fields/wizard/wizard.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ class Wizard extends React.Component {
196196
formOptions.getState().values,
197197
[ ...this.state.prevSteps, this.state.activeStep ],
198198
formOptions.getRegisteredFields,
199-
)
199+
),
200+
formOptions
200201
);
201202

202203
const currentStep = (

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ describe('<Wizard />', () => {
186186
expect(onSubmit).toHaveBeenCalled();
187187
});
188188

189-
it('should go to next step correctly and submit data', () => {
189+
it('should go to next step correctly and submit data and formOptions', () => {
190190
const onSubmit = jest.fn();
191+
const formOptions = { ...initialProps.formOptions, onSubmit, getRegisteredFields: getRegisteredFieldsSchemaMock };
192+
191193
const wrapper = mount(<Wizard
192194
{ ...initialProps }
193-
formOptions={{ ...initialProps.formOptions, onSubmit, getRegisteredFields: getRegisteredFieldsSchemaMock }}
195+
formOptions={ formOptions }
194196
fields={ schema }
195197
/>);
196198
nextButtonClickWithHeader(wrapper);
@@ -203,7 +205,7 @@ describe('<Wizard />', () => {
203205
expect(onSubmit).toHaveBeenCalledWith({
204206
'foo-field': 'foo-field-value',
205207
'bar-field': 'bar-field-value',
206-
});
208+
}, formOptions);
207209
});
208210

209211
it('should pass values to cancel button', () => {
@@ -234,9 +236,16 @@ describe('<Wizard />', () => {
234236

235237
it('should submit data when nested schema', () => {
236238
const onSubmit = jest.fn();
239+
const formOptions = {
240+
...initialProps.formOptions,
241+
onSubmit,
242+
getRegisteredFields: getRegisteredFieldsNestedSchemaMock,
243+
getState: getValuesNestedSchema,
244+
};
245+
237246
const wrapper = mount(<Wizard
238247
{ ...initialProps }
239-
formOptions={{ ...initialProps.formOptions, onSubmit, getRegisteredFields: getRegisteredFieldsNestedSchemaMock, getState: getValuesNestedSchema }}
248+
formOptions={ formOptions }
240249
fields={ nestedSchema }
241250
/>);
242251

@@ -250,7 +259,7 @@ describe('<Wizard />', () => {
250259
'bar-field': 'bar-field-value',
251260
},
252261
},
253-
});
262+
}, formOptions);
254263
});
255264

256265
it('should build simple navigation', () => {

0 commit comments

Comments
 (0)