Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(core): test case for query field error issue and pr #3995

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/core/src/__tests__/array.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,47 @@ test('array field move up/down then fields move', () => {
expect(form.fields['array.3.value']).toBe(line3)
})

// 重现 issues #3932 , 补全 PR #3992 测试用例
test('lazy array field query each', () => {
const form = attach(createForm())
const array = attach(
form.createArrayField({
name: 'array',
})
)

const init = Array.from({ length: 6 }).map((_, i) => ({ value: i }))
array.setValue(init)

// page1: 0, 1
// page2: 2, 3 untouch
// page3: 4, 5
init.forEach((item) => {
const len = item.value
//2, 3
if (len >= 2 && len <= 3) {
} else {
// 0, 1, 4, 5
attach(
form.createField({
name: 'value',
basePath: 'array.' + len,
})
)
}
})

array.insert(1, { value: '11' })
expect(() => form.query('*').take()).not.toThrowError()
expect(Object.keys(form.fields)).toEqual([
'array',
'array.0.value',
'array.5.value',
'array.2.value',
'array.6.value',
])
})

test('void children', () => {
const form = attach(createForm())
const array = attach(
Expand Down