@@ -9,10 +9,10 @@ import { Field } from './Field';
99jest . mock ( '../../../_internal/hooks/use-warn' ) ;
1010
1111describe ( 'Legacy <Field />' , ( ) => {
12- it ( 'should set default value as value' , ( ) => {
12+ it . skip ( 'should set default value as value' , ( ) => {
1313 const { getByRole, formInstance } = renderWithForm (
1414 < Field name = "test" defaultValue = "Hello, World!" >
15- < TextInput label = "test" />
15+ < TextInput name = "test" label = "test" />
1616 </ Field > ,
1717 ) ;
1818
@@ -22,7 +22,7 @@ describe('Legacy <Field />', () => {
2222 expect ( formInstance . getFieldValue ( 'test' ) ) . toBe ( 'Hello, World!' ) ;
2323 } ) ;
2424
25- it ( 'should update default value' , ( ) => {
25+ it . skip ( 'should update default value' , ( ) => {
2626 const { rerender, formInstance } = renderWithForm (
2727 < Field name = "test" defaultValue = "Hello, World!" >
2828 < TextInput label = "test" />
@@ -40,7 +40,7 @@ describe('Legacy <Field />', () => {
4040 expect ( formInstance . getFieldValue ( 'test' ) ) . toBe ( 'World!' ) ;
4141 } ) ;
4242
43- it ( 'should not update default value if field is touched' , async ( ) => {
43+ it . skip ( 'should not update default value if field is touched' , async ( ) => {
4444 const { rerender, formInstance, getByRole } = renderWithForm (
4545 < Field name = "test" defaultValue = "Hello, World!" >
4646 < TextInput label = "test" />
@@ -51,10 +51,8 @@ describe('Legacy <Field />', () => {
5151
5252 const input = getByRole ( 'textbox' ) ;
5353
54- await act ( async ( ) => {
55- await userEvent . clear ( input ) ;
56- await userEvent . type ( input , 'Test!' ) ;
57- } ) ;
54+ await userEvent . clear ( input ) ;
55+ await userEvent . type ( input , 'Test!' ) ;
5856
5957 rerender (
6058 < Field name = "test" defaultValue = "World!" >
@@ -74,10 +72,8 @@ describe('Legacy <Field />', () => {
7472
7573 const input = getByRole ( 'textbox' ) ;
7674
77- await act ( async ( ) => {
78- await userEvent . clear ( input ) ;
79- await userEvent . type ( input , 'Hello!' ) ;
80- } ) ;
75+ await userEvent . clear ( input ) ;
76+ await userEvent . type ( input , 'Hello!' ) ;
8177
8278 rerender (
8379 < Field name = "test" defaultValue = "World!" >
@@ -90,16 +86,21 @@ describe('Legacy <Field />', () => {
9086
9187 it ( 'should change value' , async ( ) => {
9288 const { getByRole, formInstance } = renderWithForm (
93- < Field name = "test" defaultValue = "Hello" >
89+ < Field name = "test" >
9490 < TextInput label = "test" />
9591 </ Field > ,
92+ {
93+ formProps : {
94+ defaultValues : {
95+ test : 'Hello' ,
96+ } ,
97+ } ,
98+ } ,
9699 ) ;
97100
98101 const input = getByRole ( 'textbox' ) ;
99102
100- await act ( async ( ) => {
101- await userEvent . type ( input , ', World!' ) ;
102- } ) ;
103+ await userEvent . type ( input , ', World!' ) ;
103104
104105 expect ( input ) . toHaveValue ( 'Hello, World!' ) ;
105106 expect ( formInstance . getFieldValue ( 'test' ) ) . toBe ( 'Hello, World!' ) ;
@@ -147,9 +148,7 @@ describe('Legacy <Field />', () => {
147148
148149 expect ( cliRadio ) . toBeChecked ( ) ;
149150
150- await act ( async ( ) => {
151- await userEvent . click ( gitRadio ) ;
152- } ) ;
151+ await userEvent . click ( gitRadio ) ;
153152
154153 expect ( gitRadio ) . toBeChecked ( ) ;
155154 } ) ;
@@ -159,27 +158,26 @@ describe('Legacy <Field />', () => {
159158 const [ deployMode ] = useState ( 'git' ) ;
160159
161160 return (
162- < Radio . Group
163- defaultValue = "cli"
164- label = "Deploy mode"
165- name = "test"
166- value = { deployMode }
167- >
161+ < Radio . Group label = "Deploy mode" name = "test" value = { deployMode } >
168162 < Radio value = "cli" > Deploy with CLI</ Radio >
169163 < Radio value = "git" > Deploy with GIT</ Radio >
170164 </ Radio . Group >
171165 ) ;
172166 }
173- const { getByRole, formInstance } = renderWithForm ( < Content /> ) ;
167+ const { getByRole, formInstance } = renderWithForm ( < Content /> , {
168+ formProps : {
169+ defaultValues : {
170+ test : 'cli' ,
171+ } ,
172+ } ,
173+ } ) ;
174174
175175 const cliRadio = getByRole ( 'radio' , { name : 'Deploy with CLI' } ) ;
176176 const gitRadio = getByRole ( 'radio' , { name : 'Deploy with GIT' } ) ;
177177
178178 expect ( cliRadio ) . toBeChecked ( ) ;
179179
180- await act ( async ( ) => {
181- await userEvent . click ( gitRadio ) ;
182- } ) ;
180+ await userEvent . click ( gitRadio ) ;
183181
184182 expect ( formInstance . getFieldValue ( 'test' ) ) . toBe ( 'git' ) ;
185183 expect ( gitRadio ) . toBeChecked ( ) ;
@@ -197,7 +195,7 @@ describe('Legacy <Field />', () => {
197195
198196 const cliRadio = getByRole ( 'radio' , { name : 'Deploy with CLI' } ) ;
199197
200- await act ( async ( ) => await userEvent . click ( cliRadio ) ) ;
198+ await userEvent . click ( cliRadio ) ;
201199
202200 expect ( formInstance . getFieldValue ( 'test' ) ) . toBe ( 'cli' ) ;
203201 expect ( onChange ) . toHaveBeenCalled ( ) ;
0 commit comments