Skip to content

Commit 9a49d45

Browse files
committed
test: test driven
1 parent cbf2162 commit 9a49d45

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/list.test.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,4 +1042,37 @@ describe('Form.List', () => {
10421042

10431043
expect(onFinishFailed).toHaveBeenCalled();
10441044
});
1045+
1046+
it('List should have correct onValuesChange', () => {
1047+
const onValuesChange = jest.fn();
1048+
1049+
const [container] = generateForm(
1050+
fields => (
1051+
<div>
1052+
{fields.map(field => (
1053+
<div key={field.key}>
1054+
<Field {...field} name={[field.name, 'first']}>
1055+
<Input />
1056+
</Field>
1057+
<Field {...field} name={[field.name, 'last']}>
1058+
<Input />
1059+
</Field>
1060+
</div>
1061+
))}
1062+
</div>
1063+
),
1064+
{
1065+
initialValues: {
1066+
list: [{ first: 'light' }],
1067+
},
1068+
onValuesChange,
1069+
},
1070+
);
1071+
1072+
fireEvent.change(getInput(container, 1), { target: { value: 'little' } });
1073+
expect(onValuesChange).toHaveBeenCalledWith(
1074+
{ list: [{ last: 'little' }] },
1075+
{ list: [{ first: 'light', last: 'little' }] },
1076+
);
1077+
});
10451078
});

0 commit comments

Comments
 (0)