File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ export class FieldApi<TData, TFormData> {
132
132
meta : this . getMeta ( ) ?? {
133
133
isValidating : false ,
134
134
isTouched : false ,
135
- ...this . options . defaultMeta ,
135
+ ...opts . defaultMeta ,
136
136
} ,
137
137
} ,
138
138
{
Original file line number Diff line number Diff line change @@ -19,21 +19,31 @@ describe('field api', () => {
19
19
expect ( field . getValue ( ) ) . toBe ( 'test' )
20
20
} )
21
21
22
- it ( 'should set a value correctly ' , ( ) => {
23
- const form = new FormApi ( {
24
- defaultValues : {
25
- name : 'test' ,
26
- } ,
22
+ it ( 'should get default meta ' , ( ) => {
23
+ const form = new FormApi ( )
24
+ const field = new FieldApi ( {
25
+ form ,
26
+ name : 'name' ,
27
27
} )
28
28
29
+ expect ( field . getMeta ( ) ) . toEqual ( {
30
+ isTouched : false ,
31
+ isValidating : false ,
32
+ } )
33
+ } )
34
+
35
+ it ( 'should allow to set default meta' , ( ) => {
36
+ const form = new FormApi ( )
29
37
const field = new FieldApi ( {
30
38
form,
31
39
name : 'name' ,
40
+ defaultMeta : { isTouched : true } ,
32
41
} )
33
42
34
- field . setValue ( 'other' )
35
-
36
- expect ( field . getValue ( ) ) . toBe ( 'other' )
43
+ expect ( field . getMeta ( ) ) . toEqual ( {
44
+ isTouched : true ,
45
+ isValidating : false ,
46
+ } )
37
47
} )
38
48
39
49
it ( 'should set a value correctly' , ( ) => {
You can’t perform that action at this time.
0 commit comments