Skip to content

Commit d40193a

Browse files
committed
test: improve list case
1 parent edc85ac commit d40193a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

tests/list.test.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,21 @@ describe('Form.List', () => {
604604
(fields, operation) => (
605605
<div>
606606
{fields.map(field => (
607-
<Field {...field} key={field.key} name={[field.name, 'first']}>
608-
<Input />
609-
</Field>
607+
<div key={field.key}>
608+
<Field name={[field.name, 'first']}>
609+
<Input />
610+
</Field>
611+
<Field name={[field.name, 'second']}>
612+
<Input />
613+
</Field>
614+
</div>
610615
))}
616+
<button
617+
type="button"
618+
onClick={() => {
619+
operation.add();
620+
}}
621+
/>
611622
<button
612623
type="button"
613624
onClick={() => {
@@ -619,12 +630,12 @@ describe('Form.List', () => {
619630
{
620631
onValuesChange,
621632
initialValues: {
622-
list: [{ first: 'light' }, { first: 'bamboo' }],
633+
list: [{ first: 'light' }],
623634
},
624635
},
625636
);
626-
627-
wrapper.find('button').simulate('click');
637+
wrapper.find('button').first().simulate('click');
638+
wrapper.find('button').last().simulate('click');
628639
expect(onValuesChange).toHaveBeenCalledWith(expect.anything(), { list: [{ first: 'light' }] });
629640
});
630641

0 commit comments

Comments
 (0)