Skip to content

Commit 0d2128b

Browse files
committed
Update tests to latest wizard changes
1 parent 729ba2f commit 0d2128b

File tree

2 files changed

+79
-6
lines changed

2 files changed

+79
-6
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,18 @@ exports[`<Wizard /> should render correctly and unmount 1`] = `
463463
Array [
464464
Object {
465465
"index": 0,
466+
"name": "1",
466467
"primary": true,
467468
"substepOf": undefined,
469+
"substepOfTitle": undefined,
468470
"title": "foo-step",
469471
},
470472
Object {
471473
"index": 1,
474+
"name": "2",
472475
"primary": true,
473476
"substepOf": undefined,
477+
"substepOfTitle": undefined,
474478
"title": "bar-step",
475479
},
476480
]
@@ -489,14 +493,18 @@ exports[`<Wizard /> should render correctly and unmount 1`] = `
489493
Array [
490494
Object {
491495
"index": 0,
496+
"name": "1",
492497
"primary": true,
493498
"substepOf": undefined,
499+
"substepOfTitle": undefined,
494500
"title": "foo-step",
495501
},
496502
Object {
497503
"index": 1,
504+
"name": "2",
498505
"primary": true,
499506
"substepOf": undefined,
507+
"substepOfTitle": undefined,
500508
"title": "bar-step",
501509
},
502510
]
@@ -508,7 +516,7 @@ exports[`<Wizard /> should render correctly and unmount 1`] = `
508516
content="foo-step"
509517
isCurrent={true}
510518
isDisabled={false}
511-
key="foo-step"
519+
key="1"
512520
onNavItemClick={[Function]}
513521
step={0}
514522
>
@@ -529,7 +537,7 @@ exports[`<Wizard /> should render correctly and unmount 1`] = `
529537
content="bar-step"
530538
isCurrent={false}
531539
isDisabled={true}
532-
key="bar-step"
540+
key="2"
533541
onNavItemClick={[Function]}
534542
step={1}
535543
>
@@ -1660,14 +1668,18 @@ exports[`<Wizard /> should render correctly in modal and unmount 1`] = `
16601668
Array [
16611669
Object {
16621670
"index": 0,
1671+
"name": "1",
16631672
"primary": true,
16641673
"substepOf": undefined,
1674+
"substepOfTitle": undefined,
16651675
"title": "foo-step",
16661676
},
16671677
Object {
16681678
"index": 1,
1679+
"name": "2",
16691680
"primary": true,
16701681
"substepOf": undefined,
1682+
"substepOfTitle": undefined,
16711683
"title": "bar-step",
16721684
},
16731685
]
@@ -1686,14 +1698,18 @@ exports[`<Wizard /> should render correctly in modal and unmount 1`] = `
16861698
Array [
16871699
Object {
16881700
"index": 0,
1701+
"name": "1",
16891702
"primary": true,
16901703
"substepOf": undefined,
1704+
"substepOfTitle": undefined,
16911705
"title": "foo-step",
16921706
},
16931707
Object {
16941708
"index": 1,
1709+
"name": "2",
16951710
"primary": true,
16961711
"substepOf": undefined,
1712+
"substepOfTitle": undefined,
16971713
"title": "bar-step",
16981714
},
16991715
]
@@ -1705,7 +1721,7 @@ exports[`<Wizard /> should render correctly in modal and unmount 1`] = `
17051721
content="foo-step"
17061722
isCurrent={true}
17071723
isDisabled={false}
1708-
key="foo-step"
1724+
key="1"
17091725
onNavItemClick={[Function]}
17101726
step={0}
17111727
>
@@ -1726,7 +1742,7 @@ exports[`<Wizard /> should render correctly in modal and unmount 1`] = `
17261742
content="bar-step"
17271743
isCurrent={false}
17281744
isDisabled={true}
1729-
key="bar-step"
1745+
key="2"
17301746
onNavItemClick={[Function]}
17311747
step={1}
17321748
>

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

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,63 @@ describe('<Wizard />', () => {
205205
expect(enterHandle.default).toHaveBeenCalledWith(event, formOptions, '1', findCurrentStep, handleNext, handleSubmit);
206206
});
207207

208+
it('should render correctly with objects as substepOf and nodes titles', () => {
209+
schema = {
210+
fields: [
211+
{
212+
name: 'wizard',
213+
component: 'wizard',
214+
inModal: true,
215+
fields: [
216+
{
217+
title: <h1>Custom title</h1>,
218+
name: 'first-step',
219+
fields: [],
220+
nextStep: 'middle-step',
221+
substepOf: { name: 'summary', title: <h2>Custom title 2</h2> }
222+
},
223+
{
224+
name: 'middle-step',
225+
title: 'middle-step',
226+
fields: [],
227+
substepOf: 'summary',
228+
nextStep: 'end'
229+
},
230+
{
231+
name: 'end',
232+
title: <h3>Custom title 3</h3>,
233+
fields: []
234+
}
235+
]
236+
}
237+
]
238+
};
239+
240+
const wrapper = mount(<FormRenderer {...initialProps} schema={schema} />);
241+
242+
expect(
243+
wrapper
244+
.find(WizardNavItem)
245+
.first()
246+
.props().content
247+
).toEqual(<h2>Custom title 2</h2>);
248+
249+
expect(
250+
wrapper
251+
.find(WizardNavItem)
252+
.first()
253+
.children()
254+
.find(WizardNavItem)
255+
).toHaveLength(2);
256+
257+
expect(
258+
wrapper
259+
.find(WizardNavItem)
260+
.last()
261+
.props().content
262+
).toEqual(<h3>Custom title 3</h3>);
263+
});
264+
208265
it('should render correctly in modal and unmount', () => {
209266
schema = {
210267
fields: [
@@ -315,8 +372,8 @@ describe('<Wizard />', () => {
315372
loading: false,
316373
maxStepIndex: 1,
317374
navSchema: [
318-
{ index: 0, primary: true, substepOf: undefined, title: 'foo-step' },
319-
{ index: 1, primary: true, substepOf: undefined, title: 'bar-step' }
375+
{ index: 0, name: '1', primary: true, substepOf: undefined, substepOfTitle: undefined, title: 'foo-step' },
376+
{ index: 1, name: '2', primary: true, substepOf: undefined, substepOfTitle: undefined, title: 'bar-step' }
320377
],
321378
prevSteps: ['1'],
322379
registeredFieldsHistory: { 1: ['foo-field'] }

0 commit comments

Comments
 (0)