File tree 1 file changed +41
-0
lines changed
packages/core/src/__tests__
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,47 @@ test('array field move up/down then fields move', () => {
200
200
expect ( form . fields [ 'array.3.value' ] ) . toBe ( line3 )
201
201
} )
202
202
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
+
203
244
test ( 'void children' , ( ) => {
204
245
const form = attach ( createForm ( ) )
205
246
const array = attach (
You can’t perform that action at this time.
0 commit comments