Skip to content

Commit

Permalink
test(core): add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Apr 28, 2021
1 parent 105bc6a commit 6bb3bed
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/core/src/__tests__/form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ test('reset object field', async () => {
})
})

test('initialValues merge values', () => {
test('initialValues merge values before create field', () => {
const form = attach(createForm())
const array = attach(
form.createArrayField({
Expand All @@ -924,3 +924,31 @@ test('initialValues merge values', () => {
expect(array.value).toEqual([{ aa: '321' }])
expect(arr_0_aa.value).toEqual('321')
})


test('initialValues merge values after create field', () => {
const form = attach(createForm())
const aa = attach(
form.createArrayField({
name: 'aa',
initialValue:'111'
})
)
const array = attach(
form.createArrayField({
name: 'array',
})
)
const arr_0_aa = attach(
form.createField({
name: 'aa',
basePath: 'array.0',
initialValue: '123',
})
)
form.values.aa = '222'
form.values.array = [{ aa: '321' }]
expect(array.value).toEqual([{ aa: '321' }])
expect(arr_0_aa.value).toEqual('321')
expect(aa.value).toEqual('222')
})

0 comments on commit 6bb3bed

Please sign in to comment.