Skip to content

Commit

Permalink
test: improve list case
Browse files Browse the repository at this point in the history
  • Loading branch information
elevensky committed Apr 19, 2023
1 parent 9fed30e commit c89c7d2
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,21 @@ describe('Form.List', () => {
(fields, operation) => (
<div>
{fields.map(field => (
<Field {...field} key={field.key} name={[field.name, 'first']}>
<Input />
</Field>
<div key={field.key}>
<Field name={[field.name, 'first']}>
<Input />
</Field>
<Field name={[field.name, 'second']}>
<Input />
</Field>
</div>
))}
<button
type="button"
onClick={() => {
operation.add();
}}
/>
<button
type="button"
onClick={() => {
Expand All @@ -619,12 +630,12 @@ describe('Form.List', () => {
{
onValuesChange,
initialValues: {
list: [{ first: 'light' }, { first: 'bamboo' }],
list: [{ first: 'light' }],
},
},
);

wrapper.find('button').simulate('click');
wrapper.find('button').first().simulate('click');
wrapper.find('button').last().simulate('click');
expect(onValuesChange).toHaveBeenCalledWith(expect.anything(), { list: [{ first: 'light' }] });
});

Expand Down

0 comments on commit c89c7d2

Please sign in to comment.