Skip to content

Commit 31d2c8e

Browse files
authored
test(core): test case for query field error issue and pr (#3995)
1 parent 5207021 commit 31d2c8e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

packages/core/src/__tests__/array.spec.ts

+41
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,47 @@ test('array field move up/down then fields move', () => {
200200
expect(form.fields['array.3.value']).toBe(line3)
201201
})
202202

203+
// 重现 issues #3932 , 补全 PR #3992 测试用例
204+
test('lazy array field query each', () => {
205+
const form = attach(createForm())
206+
const array = attach(
207+
form.createArrayField({
208+
name: 'array',
209+
})
210+
)
211+
212+
const init = Array.from({ length: 6 }).map((_, i) => ({ value: i }))
213+
array.setValue(init)
214+
215+
// page1: 0, 1
216+
// page2: 2, 3 untouch
217+
// page3: 4, 5
218+
init.forEach((item) => {
219+
const len = item.value
220+
//2, 3
221+
if (len >= 2 && len <= 3) {
222+
} else {
223+
// 0, 1, 4, 5
224+
attach(
225+
form.createField({
226+
name: 'value',
227+
basePath: 'array.' + len,
228+
})
229+
)
230+
}
231+
})
232+
233+
array.insert(1, { value: '11' })
234+
expect(() => form.query('*').take()).not.toThrowError()
235+
expect(Object.keys(form.fields)).toEqual([
236+
'array',
237+
'array.0.value',
238+
'array.5.value',
239+
'array.2.value',
240+
'array.6.value',
241+
])
242+
})
243+
203244
test('void children', () => {
204245
const form = attach(createForm())
205246
const array = attach(

0 commit comments

Comments
 (0)