Skip to content

fix(pf4): send formOptions as second argument in wizard #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ class Wizard extends React.Component {
formOptions.getState().values,
[ ...this.state.prevSteps, this.state.activeStep ],
formOptions.getRegisteredFields,
)
),
formOptions
);

const currentStep = (
Expand Down
19 changes: 14 additions & 5 deletions packages/pf4-component-mapper/src/tests/wizard/wizard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ describe('<Wizard />', () => {
expect(onSubmit).toHaveBeenCalled();
});

it('should go to next step correctly and submit data', () => {
it('should go to next step correctly and submit data and formOptions', () => {
const onSubmit = jest.fn();
const formOptions = { ...initialProps.formOptions, onSubmit, getRegisteredFields: getRegisteredFieldsSchemaMock };

const wrapper = mount(<Wizard
{ ...initialProps }
formOptions={{ ...initialProps.formOptions, onSubmit, getRegisteredFields: getRegisteredFieldsSchemaMock }}
formOptions={ formOptions }
fields={ schema }
/>);
nextButtonClickWithHeader(wrapper);
Expand All @@ -203,7 +205,7 @@ describe('<Wizard />', () => {
expect(onSubmit).toHaveBeenCalledWith({
'foo-field': 'foo-field-value',
'bar-field': 'bar-field-value',
});
}, formOptions);
});

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

it('should submit data when nested schema', () => {
const onSubmit = jest.fn();
const formOptions = {
...initialProps.formOptions,
onSubmit,
getRegisteredFields: getRegisteredFieldsNestedSchemaMock,
getState: getValuesNestedSchema,
};

const wrapper = mount(<Wizard
{ ...initialProps }
formOptions={{ ...initialProps.formOptions, onSubmit, getRegisteredFields: getRegisteredFieldsNestedSchemaMock, getState: getValuesNestedSchema }}
formOptions={ formOptions }
fields={ nestedSchema }
/>);

Expand All @@ -250,7 +259,7 @@ describe('<Wizard />', () => {
'bar-field': 'bar-field-value',
},
},
});
}, formOptions);
});

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