File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1000,4 +1000,35 @@ describe('Form.List', () => {
10001000 } ) ;
10011001 expect ( valueRef . current ) . toEqual ( { users : [ { name : 'a' } , { name : 'b' } ] } ) ;
10021002 } ) ;
1003+
1004+ it ( 'list rules' , async ( ) => {
1005+ const onFinishFailed = jest . fn ( ) ;
1006+
1007+ const Demo = ( ) => {
1008+ return (
1009+ < Form onFinishFailed = { onFinishFailed } >
1010+ < Form . List name = "users" rules = { [ { validator : ( ) => Promise . reject ( 'error' ) } ] } >
1011+ { fields => {
1012+ return fields . map ( field => (
1013+ < InfoField name = { [ field . name , 'name' ] } key = { field . key } >
1014+ < Input />
1015+ </ InfoField >
1016+ ) ) ;
1017+ } }
1018+ </ Form . List >
1019+ < button type = "submit" data-testid = "submit" >
1020+ Submit
1021+ </ button >
1022+ </ Form >
1023+ ) ;
1024+ } ;
1025+
1026+ const { queryByTestId } = render ( < Demo /> ) ;
1027+ fireEvent . click ( queryByTestId ( 'submit' ) ) ;
1028+ await act ( async ( ) => {
1029+ await timeout ( ) ;
1030+ } ) ;
1031+
1032+ expect ( onFinishFailed ) . toHaveBeenCalled ( ) ;
1033+ } ) ;
10031034} ) ;
You can’t perform that action at this time.
0 commit comments