Skip to content

Commit c309ab6

Browse files
committed
add tests
1 parent 728e871 commit c309ab6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

packages/ra-ui-materialui/src/input/ArrayInput/ArrayInput.spec.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,42 @@ describe('<ArrayInput />', () => {
478478
await waitFor(() => {
479479
expect(screen.queryAllByRole('listitem')).toHaveLength(0);
480480
});
481+
482+
fireEvent.click(await screen.findByRole('button', { name: 'Add' }));
483+
fireEvent.change(screen.getByLabelText('Name'), {
484+
target: { value: 'Leo Tolstoy' },
485+
});
486+
fireEvent.change(screen.getByLabelText('Role'), {
487+
target: { value: 'Writer' },
488+
});
489+
490+
expect(screen.queryAllByRole('listitem')).toHaveLength(1);
491+
fireEvent.click(screen.getByRole('button', { name: 'Reset' }));
492+
await waitFor(() => {
493+
expect(screen.queryAllByRole('listitem')).toHaveLength(0); // TODO: fix it
494+
});
495+
});
496+
497+
it('should remove an empty line twice', async () => {
498+
render(<Reset />);
499+
500+
expect(screen.queryAllByRole('listitem')).toHaveLength(0);
501+
502+
fireEvent.click(await screen.findByRole('button', { name: 'Add' }));
503+
504+
expect(screen.queryAllByRole('listitem')).toHaveLength(1);
505+
fireEvent.click(screen.getByRole('button', { name: 'Reset' }));
506+
await waitFor(() => {
507+
expect(screen.queryAllByRole('listitem')).toHaveLength(0);
508+
});
509+
510+
fireEvent.click(await screen.findByRole('button', { name: 'Add' }));
511+
512+
expect(screen.queryAllByRole('listitem')).toHaveLength(1);
513+
fireEvent.click(screen.getByRole('button', { name: 'Reset' }));
514+
await waitFor(() => {
515+
expect(screen.queryAllByRole('listitem')).toHaveLength(0); // TODO: fix it
516+
});
481517
});
482518
});
483519
});

0 commit comments

Comments
 (0)