Skip to content

Commit d862d99

Browse files
committed
chore: add FieldGroupApi unit test
1 parent 79b4e74 commit d862d99

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/form-core/tests/FieldGroupApi.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,4 +888,35 @@ describe('field group api', () => {
888888
'Error',
889889
])
890890
})
891+
892+
it('should generate form field names properly with nested objects', () => {
893+
// https://github.com/TanStack/form/issues/1645
894+
const form = new FormApi({
895+
defaultValues: {
896+
complexValue: {
897+
prop1: 0,
898+
prop2: 0,
899+
},
900+
},
901+
})
902+
form.mount()
903+
904+
const group = new FieldGroupApi({
905+
defaultValues: {
906+
complexValue: {
907+
prop1: 0,
908+
prop2: 0,
909+
},
910+
},
911+
form,
912+
fields: {
913+
complexValue: 'complexValue',
914+
},
915+
})
916+
group.mount()
917+
918+
expect(group.getFormFieldName('complexValue.prop1')).toBe(
919+
'complexValue.prop1',
920+
)
921+
})
891922
})

0 commit comments

Comments
 (0)