@@ -77,7 +77,7 @@ function toVNode(node: VNodeChild): VNode {
77
77
}
78
78
79
79
function compareChildren ( vnodes : VNodeArrayChildren , expectation : VNodeArrayChildren ) {
80
- expect ( vnodes . length ) . toBe ( expectation . length )
80
+ expect ( vnodes ) . toHaveLength ( expectation . length )
81
81
82
82
for ( let index = 0 ; index < Math . min ( vnodes . length , expectation . length ) ; ++ index ) {
83
83
compareNode ( toVNode ( vnodes [ index ] ) , toVNode ( expectation [ index ] ) )
@@ -176,15 +176,15 @@ describe('addProps', () => {
176
176
177
177
expect ( count ) . toBe ( 1 )
178
178
expect ( Array . isArray ( nodes ) ) . toBe ( true )
179
- expect ( nodes . length ) . toBe ( 1 )
179
+ expect ( nodes ) . toHaveLength ( 1 )
180
180
181
181
const node = nodes [ 0 ] as VNode
182
182
183
183
expect ( isElement ( node ) ) . toBe ( true )
184
184
expect ( node . type ) . toBe ( 'div' )
185
185
expect ( node . props ?. class ) . toBe ( 'red' )
186
186
187
- expect ( startNodes . length ) . toBe ( 1 )
187
+ expect ( startNodes ) . toHaveLength ( 1 )
188
188
expect ( startNodes [ 0 ] ) . toBe ( startNode )
189
189
expect ( startNode . props ) . toBe ( null )
190
190
} )
@@ -210,24 +210,24 @@ describe('addProps', () => {
210
210
211
211
expect ( count ) . toBe ( 1 )
212
212
expect ( Array . isArray ( nodes ) ) . toBe ( true )
213
- expect ( nodes . length ) . toBe ( 1 )
213
+ expect ( nodes ) . toHaveLength ( 1 )
214
214
215
215
const node = nodes [ 0 ] as VNode
216
216
217
217
expect ( isFragment ( node ) ) . toBe ( true )
218
218
expect ( Array . isArray ( node . children ) ) . toBe ( true )
219
- expect ( node . children ?. length ) . toBe ( 1 )
219
+ expect ( node . children ) . toHaveLength ( 1 )
220
220
221
221
const child = ( node . children as VNode [ ] ) [ 0 ]
222
222
223
223
expect ( isElement ( child ) ) . toBe ( true )
224
224
expect ( child . type ) . toBe ( 'div' )
225
225
expect ( child . props ?. class ) . toBe ( 'red' )
226
226
227
- expect ( startNodes . length ) . toBe ( 1 )
227
+ expect ( startNodes ) . toHaveLength ( 1 )
228
228
expect ( startNodes [ 0 ] ) . toBe ( fragNode )
229
229
expect ( fragNode . props ) . toBe ( null )
230
- expect ( fragNode . children ?. length ) . toBe ( 1 )
230
+ expect ( fragNode . children ) . toHaveLength ( 1 )
231
231
expect ( ( fragNode . children as VNodeArrayChildren ) [ 0 ] ) . toBe ( divNode )
232
232
expect ( divNode . props ) . toBe ( null )
233
233
} )
@@ -261,7 +261,7 @@ describe('addProps', () => {
261
261
}
262
262
} )
263
263
264
- expect ( calledFor . length ) . toBe ( 3 )
264
+ expect ( calledFor ) . toHaveLength ( 3 )
265
265
expect ( calledFor . every ( node => isVNode ( node ) ) ) . toBe ( true )
266
266
expect ( calledFor [ 0 ] . type ) . toBe ( 'div' )
267
267
expect ( calledFor [ 1 ] . type ) . toBe ( 'span' )
@@ -332,7 +332,7 @@ describe('addProps', () => {
332
332
}
333
333
} )
334
334
335
- expect ( calledFor . length ) . toBe ( 6 )
335
+ expect ( calledFor ) . toHaveLength ( 6 )
336
336
expect ( calledFor . every ( node => isVNode ( node ) ) ) . toBe ( true )
337
337
expect ( calledFor [ 0 ] . type ) . toBe ( 'p' )
338
338
expect ( calledFor [ 1 ] . type ) . toMatchObject ( { template : 'abc' } )
@@ -404,7 +404,7 @@ describe('addProps', () => {
404
404
405
405
expect ( count ) . toBe ( 2 )
406
406
407
- expect ( nodes . length ) . toBe ( 3 )
407
+ expect ( nodes ) . toHaveLength ( 3 )
408
408
expect ( ( nodes [ 0 ] as VNode ) . props ?. class ) . toBe ( 'red' )
409
409
expect ( ( nodes [ 1 ] as VNode ) . props ?. class ) . toBe ( undefined )
410
410
@@ -421,7 +421,7 @@ describe('addProps', () => {
421
421
422
422
expect ( count ) . toBe ( 2 )
423
423
424
- expect ( nodes . length ) . toBe ( 3 )
424
+ expect ( nodes ) . toHaveLength ( 3 )
425
425
expect ( ( nodes [ 0 ] as VNode ) . props ?. class ) . toBe ( undefined )
426
426
expect ( ( nodes [ 1 ] as VNode ) . props ?. class ) . toBe ( 'red' )
427
427
} )
@@ -445,10 +445,10 @@ describe('addProps', () => {
445
445
446
446
expect ( count ) . toBe ( 2 )
447
447
448
- expect ( nodes . length ) . toBe ( 2 )
448
+ expect ( nodes ) . toHaveLength ( 2 )
449
449
expect ( ( nodes [ 0 ] as VNode ) . props ?. class ) . toBe ( 'red' )
450
450
expect ( nodes [ 1 ] ) . toBe ( fragment )
451
- expect ( fragment . length ) . toBe ( 1 )
451
+ expect ( fragment ) . toHaveLength ( 1 )
452
452
expect ( fragment [ 0 ] ) . toBe ( spanNode )
453
453
expect ( spanNode . props ) . toBe ( null )
454
454
} )
@@ -751,7 +751,7 @@ describe('betweenChildren', () => {
751
751
752
752
expect ( count ) . toBe ( 1 )
753
753
expect ( Array . isArray ( nodes ) ) . toBe ( true )
754
- expect ( nodes . length ) . toBe ( 3 )
754
+ expect ( nodes ) . toHaveLength ( 3 )
755
755
756
756
compareChildren ( nodes , [ h ( 'div' ) , h ( 'p' ) , h ( 'span' ) ] )
757
757
compareChildren ( startNodes , [ h ( 'div' ) , h ( 'span' ) ] )
@@ -778,7 +778,7 @@ describe('betweenChildren', () => {
778
778
779
779
expect ( count ) . toBe ( 1 )
780
780
expect ( Array . isArray ( nodes ) ) . toBe ( true )
781
- expect ( nodes . length ) . toBe ( 4 )
781
+ expect ( nodes ) . toHaveLength ( 4 )
782
782
783
783
compareChildren ( nodes , [ h ( 'div' ) , 'hello' , h ( 'strong' , null , [ 'world' ] ) , h ( 'span' ) ] )
784
784
compareChildren ( startNodes , [ h ( 'div' ) , h ( 'span' ) ] )
@@ -814,7 +814,7 @@ describe('betweenChildren', () => {
814
814
815
815
expect ( count ) . toBe ( 5 )
816
816
expect ( Array . isArray ( nodes ) ) . toBe ( true )
817
- expect ( nodes . length ) . toBe ( 14 )
817
+ expect ( nodes ) . toHaveLength ( 14 )
818
818
819
819
compareChildren ( startNodes , getStartNodes ( ) )
820
820
@@ -872,7 +872,7 @@ describe('betweenChildren', () => {
872
872
873
873
expect ( count ) . toBe ( 8 )
874
874
expect ( Array . isArray ( nodes ) ) . toBe ( true )
875
- expect ( nodes . length ) . toBe ( 17 )
875
+ expect ( nodes ) . toHaveLength ( 17 )
876
876
877
877
compareChildren ( startNodes , getStartNodes ( ) )
878
878
@@ -932,7 +932,7 @@ describe('betweenChildren', () => {
932
932
933
933
expect ( count ) . toBe ( 1 )
934
934
expect ( Array . isArray ( nodes ) ) . toBe ( true )
935
- expect ( nodes . length ) . toBe ( 9 )
935
+ expect ( nodes ) . toHaveLength ( 9 )
936
936
937
937
compareChildren ( startNodes , getStartNodes ( ) )
938
938
@@ -983,7 +983,7 @@ describe('betweenChildren', () => {
983
983
984
984
expect ( count ) . toBe ( 1 )
985
985
expect ( Array . isArray ( nodes ) ) . toBe ( true )
986
- expect ( nodes . length ) . toBe ( 10 )
986
+ expect ( nodes ) . toHaveLength ( 10 )
987
987
988
988
compareChildren ( startNodes , getStartNodes ( ) )
989
989
@@ -1038,7 +1038,7 @@ describe('betweenChildren', () => {
1038
1038
1039
1039
expect ( count ) . toBe ( 1 )
1040
1040
expect ( Array . isArray ( nodes ) ) . toBe ( true )
1041
- expect ( nodes . length ) . toBe ( 10 )
1041
+ expect ( nodes ) . toHaveLength ( 10 )
1042
1042
1043
1043
compareChildren ( startNodes , getStartNodes ( ) )
1044
1044
@@ -1090,7 +1090,7 @@ describe('betweenChildren', () => {
1090
1090
1091
1091
expect ( count ) . toBe ( 1 )
1092
1092
expect ( Array . isArray ( nodes ) ) . toBe ( true )
1093
- expect ( nodes . length ) . toBe ( 10 )
1093
+ expect ( nodes ) . toHaveLength ( 10 )
1094
1094
1095
1095
compareChildren ( startNodes , getStartNodes ( ) )
1096
1096
@@ -1139,7 +1139,7 @@ describe('betweenChildren', () => {
1139
1139
1140
1140
expect ( count ) . toBe ( 1 )
1141
1141
expect ( Array . isArray ( nodes ) ) . toBe ( true )
1142
- expect ( nodes . length ) . toBe ( 3 )
1142
+ expect ( nodes ) . toHaveLength ( 3 )
1143
1143
1144
1144
compareChildren ( startNodes , getStartNodes ( ) )
1145
1145
@@ -1188,7 +1188,7 @@ describe('betweenChildren', () => {
1188
1188
1189
1189
expect ( count ) . toBe ( 6 )
1190
1190
expect ( Array . isArray ( nodes ) ) . toBe ( true )
1191
- expect ( nodes . length ) . toBe ( 2 )
1191
+ expect ( nodes ) . toHaveLength ( 2 )
1192
1192
1193
1193
compareChildren ( startNodes , getStartNodes ( ) )
1194
1194
@@ -1293,7 +1293,7 @@ describe('someChild', () => {
1293
1293
} )
1294
1294
1295
1295
expect ( out ) . toBe ( false )
1296
- expect ( calledFor . length ) . toBe ( 4 )
1296
+ expect ( calledFor ) . toHaveLength ( 4 )
1297
1297
expect ( calledFor [ 0 ] ) . toBe ( startNodes [ 0 ] )
1298
1298
expect ( calledFor [ 1 ] ) . toBe ( ( startNodes [ 1 ] . children as VNode [ ] ) [ 0 ] )
1299
1299
expect ( calledFor [ 2 ] ) . toBe ( ( startNodes [ 1 ] . children as VNode [ ] ) [ 1 ] )
@@ -1308,7 +1308,7 @@ describe('someChild', () => {
1308
1308
} )
1309
1309
1310
1310
expect ( out ) . toBe ( true )
1311
- expect ( calledFor . length ) . toBe ( 3 )
1311
+ expect ( calledFor ) . toHaveLength ( 3 )
1312
1312
expect ( calledFor [ 0 ] ) . toBe ( startNodes [ 0 ] )
1313
1313
expect ( calledFor [ 1 ] ) . toBe ( ( startNodes [ 1 ] . children as VNode [ ] ) [ 0 ] )
1314
1314
expect ( calledFor [ 2 ] ) . toBe ( ( startNodes [ 1 ] . children as VNode [ ] ) [ 1 ] )
@@ -1322,7 +1322,7 @@ describe('someChild', () => {
1322
1322
} )
1323
1323
1324
1324
expect ( out ) . toBe ( true )
1325
- expect ( calledFor . length ) . toBe ( 2 )
1325
+ expect ( calledFor ) . toHaveLength ( 2 )
1326
1326
expect ( calledFor [ 0 ] ) . toBe ( startNodes [ 0 ] )
1327
1327
expect ( calledFor [ 1 ] ) . toBe ( ( startNodes [ 1 ] . children as VNode [ ] ) [ 0 ] )
1328
1328
} )
@@ -1339,7 +1339,7 @@ describe('someChild', () => {
1339
1339
return false
1340
1340
} , ALL_VNODES )
1341
1341
1342
- expect ( calledFor . length ) . toBe ( 7 )
1342
+ expect ( calledFor ) . toHaveLength ( 7 )
1343
1343
1344
1344
calledFor . length = 0
1345
1345
@@ -1349,7 +1349,7 @@ describe('someChild', () => {
1349
1349
return false
1350
1350
} , SKIP_COMMENTS )
1351
1351
1352
- expect ( calledFor . length ) . toBe ( 6 )
1352
+ expect ( calledFor ) . toHaveLength ( 6 )
1353
1353
1354
1354
calledFor . length = 0
1355
1355
@@ -1359,7 +1359,7 @@ describe('someChild', () => {
1359
1359
return false
1360
1360
} , COMPONENTS_AND_ELEMENTS )
1361
1361
1362
- expect ( calledFor . length ) . toBe ( 4 )
1362
+ expect ( calledFor ) . toHaveLength ( 4 )
1363
1363
1364
1364
calledFor . length = 0
1365
1365
@@ -1369,7 +1369,7 @@ describe('someChild', () => {
1369
1369
return false
1370
1370
} , { component : true } )
1371
1371
1372
- expect ( calledFor . length ) . toBe ( 1 )
1372
+ expect ( calledFor ) . toHaveLength ( 1 )
1373
1373
1374
1374
calledFor . length = 0
1375
1375
@@ -1379,7 +1379,7 @@ describe('someChild', () => {
1379
1379
return false
1380
1380
} , { } )
1381
1381
1382
- expect ( calledFor . length ) . toBe ( 0 )
1382
+ expect ( calledFor ) . toHaveLength ( 0 )
1383
1383
1384
1384
calledFor . length = 0
1385
1385
@@ -1389,7 +1389,7 @@ describe('someChild', () => {
1389
1389
return false
1390
1390
} , { comment : true } )
1391
1391
1392
- expect ( calledFor . length ) . toBe ( 1 )
1392
+ expect ( calledFor ) . toHaveLength ( 1 )
1393
1393
1394
1394
calledFor . length = 0
1395
1395
@@ -1399,7 +1399,7 @@ describe('someChild', () => {
1399
1399
return false
1400
1400
} , { text : true } )
1401
1401
1402
- expect ( calledFor . length ) . toBe ( 2 )
1402
+ expect ( calledFor ) . toHaveLength ( 2 )
1403
1403
1404
1404
calledFor . length = 0
1405
1405
@@ -1409,7 +1409,7 @@ describe('someChild', () => {
1409
1409
return false
1410
1410
} , { element : true } )
1411
1411
1412
- expect ( calledFor . length ) . toBe ( 3 )
1412
+ expect ( calledFor ) . toHaveLength ( 3 )
1413
1413
} )
1414
1414
} )
1415
1415
@@ -1426,7 +1426,7 @@ describe('everyChild', () => {
1426
1426
} )
1427
1427
1428
1428
expect ( out ) . toBe ( true )
1429
- expect ( calledFor . length ) . toBe ( 4 )
1429
+ expect ( calledFor ) . toHaveLength ( 4 )
1430
1430
expect ( calledFor [ 0 ] . type ) . toBe ( 'a' )
1431
1431
expect ( calledFor [ 1 ] . type ) . toBe ( 'div' )
1432
1432
expect ( calledFor [ 2 ] . type ) . toBe ( 'span' )
@@ -1441,7 +1441,7 @@ describe('everyChild', () => {
1441
1441
} )
1442
1442
1443
1443
expect ( out ) . toBe ( false )
1444
- expect ( calledFor . length ) . toBe ( 2 )
1444
+ expect ( calledFor ) . toHaveLength ( 2 )
1445
1445
expect ( calledFor [ 0 ] . type ) . toBe ( 'a' )
1446
1446
expect ( calledFor [ 1 ] . type ) . toBe ( 'div' )
1447
1447
} )
@@ -1462,7 +1462,7 @@ describe('eachChild', () => {
1462
1462
} )
1463
1463
1464
1464
expect ( out ) . toBe ( undefined )
1465
- expect ( calledFor . length ) . toBe ( 4 )
1465
+ expect ( calledFor ) . toHaveLength ( 4 )
1466
1466
expect ( calledFor [ 0 ] ) . toBe ( startNodes [ 0 ] )
1467
1467
expect ( isText ( calledFor [ 1 ] ) && getText ( calledFor [ 1 ] ) ) . toBe ( 'Text' )
1468
1468
expect ( calledFor [ 2 ] . type ) . toBe ( 'span' )
@@ -1483,7 +1483,7 @@ describe('findChild', () => {
1483
1483
} )
1484
1484
1485
1485
expect ( out ) . toBe ( undefined )
1486
- expect ( calledFor . length ) . toBe ( 4 )
1486
+ expect ( calledFor ) . toHaveLength ( 4 )
1487
1487
expect ( calledFor [ 0 ] ) . toBe ( startNodes [ 0 ] )
1488
1488
expect ( isText ( calledFor [ 1 ] ) && getText ( calledFor [ 1 ] ) ) . toBe ( 'Text' )
1489
1489
expect ( calledFor [ 2 ] . type ) . toBe ( 'span' )
@@ -1498,7 +1498,7 @@ describe('findChild', () => {
1498
1498
} )
1499
1499
1500
1500
expect ( out ?. type ) . toBe ( 'span' )
1501
- expect ( calledFor . length ) . toBe ( 3 )
1501
+ expect ( calledFor ) . toHaveLength ( 3 )
1502
1502
expect ( calledFor [ 0 ] ) . toBe ( startNodes [ 0 ] )
1503
1503
expect ( isText ( calledFor [ 1 ] ) && getText ( calledFor [ 1 ] ) ) . toBe ( 'Text' )
1504
1504
expect ( calledFor [ 2 ] . type ) . toBe ( 'span' )
0 commit comments