Skip to content

Commit 4a8d31e

Browse files
committed
Use stories in tests
1 parent 14fb192 commit 4a8d31e

File tree

1 file changed

+7
-43
lines changed

1 file changed

+7
-43
lines changed

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

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import { SimpleForm } from '../../form';
1818
import { ArrayInput } from './ArrayInput';
1919
import { TextInput } from '../TextInput';
2020
import { SimpleFormIterator } from './SimpleFormIterator';
21-
import { Basic } from './SimpleFormIterator.stories';
21+
import {
22+
Basic,
23+
DefaultValue,
24+
DefaultValueWithFormDataConsumer,
25+
} from './SimpleFormIterator.stories';
2226

2327
describe('<SimpleFormIterator />', () => {
2428
// bypass confirm leave form with unsaved changes
@@ -418,22 +422,7 @@ describe('<SimpleFormIterator />', () => {
418422
});
419423

420424
it('should not reapply default values set at form level after removing and then re-adding one row', async () => {
421-
render(
422-
<Wrapper>
423-
<SimpleForm
424-
defaultValues={{
425-
emails: [{ email: '[email protected]', name: 'test' }],
426-
}}
427-
>
428-
<ArrayInput source="emails">
429-
<SimpleFormIterator>
430-
<TextInput source="email" label="Email" />
431-
<TextInput source="name" label="Name" />
432-
</SimpleFormIterator>
433-
</ArrayInput>
434-
</SimpleForm>
435-
</Wrapper>
436-
);
425+
render(<DefaultValue />);
437426

438427
const removeFirstButton = getByLabelText(
439428
// @ts-ignore
@@ -479,32 +468,7 @@ describe('<SimpleFormIterator />', () => {
479468
});
480469

481470
it('should not reapply default values set at form level after removing and then re-adding one row, even with FormDataConsumer', async () => {
482-
render(
483-
<Wrapper>
484-
<SimpleForm
485-
defaultValues={{
486-
emails: [{ email: '[email protected]', name: 'test' }],
487-
}}
488-
>
489-
<ArrayInput source="emails">
490-
<SimpleFormIterator>
491-
<FormDataConsumer>
492-
{() => (
493-
<>
494-
<TextInput
495-
source="email"
496-
label="Email"
497-
defaultValue="[email protected]"
498-
/>
499-
<TextInput source="name" label="Name" />
500-
</>
501-
)}
502-
</FormDataConsumer>
503-
</SimpleFormIterator>
504-
</ArrayInput>
505-
</SimpleForm>
506-
</Wrapper>
507-
);
471+
render(<DefaultValueWithFormDataConsumer />);
508472

509473
const removeFirstButton = getByLabelText(
510474
// @ts-ignore

0 commit comments

Comments
 (0)