@@ -14,6 +14,8 @@ jest.mock("react-i18next", () => {
1414 } ;
1515} ) ;
1616
17+ ( window as any ) . getComputedStyle = jest . fn ( ( ) => ( { } ) ) ;
18+
1719const columns = [
1820 {
1921 dataIndex : "name" ,
@@ -447,7 +449,7 @@ describe("pagination", () => {
447449 ) [ 1 ] as Element ;
448450 fireEvent . click ( pageItem ) ;
449451 } ) ;
450- expect ( onPageChange ) . lastCalledWith (
452+ expect ( onPageChange ) . toHaveBeenLastCalledWith (
451453 expect . objectContaining ( {
452454 detail : {
453455 page : 2 ,
@@ -463,15 +465,15 @@ describe("pagination", () => {
463465 ) [ 2 ] as Element ;
464466 fireEvent . click ( pageSizeOptionItem ) ;
465467 } ) ;
466- expect ( onPageChange ) . lastCalledWith (
468+ expect ( onPageChange ) . toHaveBeenLastCalledWith (
467469 expect . objectContaining ( {
468470 detail : {
469471 page : 1 ,
470472 pageSize : 20 ,
471473 } ,
472474 } )
473475 ) ;
474- expect ( onPageSizeChange ) . lastCalledWith (
476+ expect ( onPageSizeChange ) . toHaveBeenLastCalledWith (
475477 expect . objectContaining ( {
476478 detail : {
477479 page : 1 ,
@@ -644,7 +646,7 @@ describe("front search", () => {
644646 fireEvent . click ( ageTh ) ;
645647 } ) ;
646648 expect ( ageTh . getAttribute ( "aria-sort" ) ) . toBe ( "descending" ) ;
647- expect ( onSort ) . lastCalledWith (
649+ expect ( onSort ) . toHaveBeenLastCalledWith (
648650 expect . objectContaining ( {
649651 detail : {
650652 columnKey : "age" ,
@@ -661,8 +663,8 @@ describe("front search", () => {
661663 await act ( async ( ) => {
662664 fireEvent . click ( ageTh ) ;
663665 } ) ;
664- expect ( ageTh . getAttribute ( "aria-sort" ) ) . toBeNull ;
665- expect ( onSort ) . lastCalledWith (
666+ expect ( ageTh . getAttribute ( "aria-sort" ) ) . toBeNull ( ) ;
667+ expect ( onSort ) . toHaveBeenLastCalledWith (
666668 expect . objectContaining ( {
667669 detail : null ,
668670 } )
@@ -782,7 +784,7 @@ describe("sortable", () => {
782784 fireEvent . click ( ageTh ) ;
783785 } ) ;
784786 expect ( ageTh . getAttribute ( "aria-sort" ) ) . toBe ( "descending" ) ;
785- expect ( onSort ) . lastCalledWith (
787+ expect ( onSort ) . toHaveBeenLastCalledWith (
786788 expect . objectContaining ( {
787789 detail : {
788790 columnKey : "age" ,
@@ -799,7 +801,7 @@ describe("sortable", () => {
799801 } ) ;
800802 expect ( ageTh . getAttribute ( "aria-sort" ) ) . toBeNull ( ) ;
801803 expect ( addressTh . getAttribute ( "aria-sort" ) ) . toBe ( "ascending" ) ;
802- expect ( onSort ) . lastCalledWith (
804+ expect ( onSort ) . toHaveBeenLastCalledWith (
803805 expect . objectContaining ( {
804806 detail : {
805807 columnKey : "address" ,
@@ -874,7 +876,7 @@ describe("sortable", () => {
874876 } ) ;
875877 expect ( ageTh . getAttribute ( "aria-sort" ) ) . toBe ( "descending" ) ;
876878 expect ( addressTh . getAttribute ( "aria-sort" ) ) . toBe ( "descending" ) ;
877- expect ( onSort ) . lastCalledWith (
879+ expect ( onSort ) . toHaveBeenLastCalledWith (
878880 expect . objectContaining ( {
879881 detail : [
880882 {
@@ -892,7 +894,7 @@ describe("sortable", () => {
892894 await act ( async ( ) => {
893895 fireEvent . click ( ageTh ) ;
894896 } ) ;
895- expect ( onSort ) . lastCalledWith (
897+ expect ( onSort ) . toHaveBeenLastCalledWith (
896898 expect . objectContaining ( {
897899 detail : {
898900 columnKey : "address" ,
@@ -904,7 +906,7 @@ describe("sortable", () => {
904906 await act ( async ( ) => {
905907 fireEvent . click ( addressTh ) ;
906908 } ) ;
907- expect ( onSort ) . lastCalledWith (
909+ expect ( onSort ) . toHaveBeenLastCalledWith (
908910 expect . objectContaining ( {
909911 detail : null ,
910912 } )
@@ -953,7 +955,7 @@ describe("rowSelection", () => {
953955 ) [ 1 ] as Element
954956 ) ;
955957 } ) ;
956- expect ( onRowSelect ) . lastCalledWith (
958+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
957959 expect . objectContaining ( {
958960 detail : {
959961 keys : [ dataSource . list [ 0 ] . key ] ,
@@ -974,7 +976,7 @@ describe("rowSelection", () => {
974976 ) [ 0 ] as Element
975977 ) ;
976978 } ) ;
977- expect ( onRowSelect ) . lastCalledWith (
979+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
978980 expect . objectContaining ( {
979981 detail : {
980982 keys : dataSource . list . slice ( 0 , 5 ) . map ( ( v ) => v . key ) ,
@@ -1000,7 +1002,7 @@ describe("rowSelection", () => {
10001002 ) [ 0 ] as Element
10011003 ) ;
10021004 } ) ;
1003- expect ( onRowSelect ) . lastCalledWith (
1005+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
10041006 expect . objectContaining ( {
10051007 detail : {
10061008 keys : dataSource . list . slice ( 0 , 10 ) . map ( ( v ) => v . key ) ,
@@ -1018,7 +1020,7 @@ describe("rowSelection", () => {
10181020 element . shadowRoot ?. querySelector ( ".select-info eo-link" ) as Element
10191021 ) ;
10201022 } ) ;
1021- expect ( onRowSelect ) . lastCalledWith (
1023+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
10221024 expect . objectContaining ( {
10231025 detail : {
10241026 keys : [ ] ,
@@ -1066,7 +1068,7 @@ describe("rowSelection", () => {
10661068 ) [ 1 ] as Element
10671069 ) ;
10681070 } ) ;
1069- expect ( onRowSelect ) . lastCalledWith (
1071+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
10701072 expect . objectContaining ( {
10711073 detail : {
10721074 keys : [ treeDataSource . list [ 0 ] . key ] ,
@@ -1085,7 +1087,7 @@ describe("rowSelection", () => {
10851087 ) [ 2 ] as Element
10861088 ) ;
10871089 } ) ;
1088- expect ( onRowSelect ) . lastCalledWith (
1090+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
10891091 expect . objectContaining ( {
10901092 detail : {
10911093 keys : [
@@ -1108,7 +1110,7 @@ describe("rowSelection", () => {
11081110 ) [ 0 ] as Element
11091111 ) ;
11101112 } ) ;
1111- expect ( onRowSelect ) . lastCalledWith (
1113+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
11121114 expect . objectContaining ( {
11131115 detail : {
11141116 keys : getAllKeys ( {
@@ -1160,7 +1162,7 @@ describe("rowSelection", () => {
11601162 ) [ 1 ] as Element
11611163 ) ;
11621164 } ) ;
1163- expect ( onRowSelect ) . lastCalledWith (
1165+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
11641166 expect . objectContaining ( {
11651167 detail : {
11661168 keys : [
@@ -1182,7 +1184,7 @@ describe("rowSelection", () => {
11821184 ) [ 2 ] as Element
11831185 ) ;
11841186 } ) ;
1185- expect ( onRowSelect ) . lastCalledWith (
1187+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
11861188 expect . objectContaining ( {
11871189 detail : {
11881190 // Not including halfChecked
@@ -1208,7 +1210,7 @@ describe("rowSelection", () => {
12081210 ) ;
12091211 } ) ;
12101212 // keys order will changed
1211- expect ( onRowSelect ) . lastCalledWith (
1213+ expect ( onRowSelect ) . toHaveBeenLastCalledWith (
12121214 expect . objectContaining ( {
12131215 detail : {
12141216 keys : expect . any ( Array ) ,
@@ -1291,8 +1293,8 @@ describe("expandable", () => {
12911293 ) [ 1 ] as Element
12921294 ) ;
12931295 } ) ;
1294- expect ( onRowExpand ) . not . toBeCalled ( ) ;
1295- expect ( onExpandedRowsChange ) . not . toBeCalled ( ) ;
1296+ expect ( onRowExpand ) . not . toHaveBeenCalled ( ) ;
1297+ expect ( onExpandedRowsChange ) . not . toHaveBeenCalled ( ) ;
12961298
12971299 await act ( async ( ) => {
12981300 fireEvent . click (
@@ -1306,15 +1308,15 @@ describe("expandable", () => {
13061308 ".ant-table-expanded-row .expanded-row-brick"
13071309 )
13081310 ) . toBeTruthy ( ) ;
1309- expect ( onRowExpand ) . lastCalledWith (
1311+ expect ( onRowExpand ) . toHaveBeenLastCalledWith (
13101312 expect . objectContaining ( {
13111313 detail : {
13121314 expanded : true ,
13131315 record : dataSource . list [ 0 ] ,
13141316 } ,
13151317 } )
13161318 ) ;
1317- expect ( onExpandedRowsChange ) . lastCalledWith (
1319+ expect ( onExpandedRowsChange ) . toHaveBeenLastCalledWith (
13181320 expect . objectContaining ( {
13191321 detail : [ dataSource . list [ 0 ] . key ] ,
13201322 } )
@@ -1327,15 +1329,15 @@ describe("expandable", () => {
13271329 ) [ 0 ] as Element
13281330 ) ;
13291331 } ) ;
1330- expect ( onRowExpand ) . lastCalledWith (
1332+ expect ( onRowExpand ) . toHaveBeenLastCalledWith (
13311333 expect . objectContaining ( {
13321334 detail : {
13331335 expanded : false ,
13341336 record : dataSource . list [ 0 ] ,
13351337 } ,
13361338 } )
13371339 ) ;
1338- expect ( onExpandedRowsChange ) . lastCalledWith (
1340+ expect ( onExpandedRowsChange ) . toHaveBeenLastCalledWith (
13391341 expect . objectContaining ( {
13401342 detail : [ ] ,
13411343 } )
@@ -1379,15 +1381,15 @@ describe("expandable", () => {
13791381 expect (
13801382 element . shadowRoot ?. querySelectorAll ( "tbody .ant-table-row" ) . length
13811383 ) . toBe ( treeDataSource . list . length + treeDataSource . list [ 1 ] . student . length ) ;
1382- expect ( onRowExpand ) . lastCalledWith (
1384+ expect ( onRowExpand ) . toHaveBeenLastCalledWith (
13831385 expect . objectContaining ( {
13841386 detail : {
13851387 expanded : true ,
13861388 record : treeDataSource . list [ 1 ] ,
13871389 } ,
13881390 } )
13891391 ) ;
1390- expect ( onExpandedRowsChange ) . lastCalledWith (
1392+ expect ( onExpandedRowsChange ) . toHaveBeenLastCalledWith (
13911393 expect . objectContaining ( {
13921394 detail : [ treeDataSource . list [ 1 ] . key ] ,
13931395 } )
@@ -1407,15 +1409,15 @@ describe("expandable", () => {
14071409 treeDataSource . list [ 1 ] . student . length +
14081410 ( treeDataSource . list [ 1 ] . student [ 2 ] . student ?. length as any )
14091411 ) ;
1410- expect ( onRowExpand ) . lastCalledWith (
1412+ expect ( onRowExpand ) . toHaveBeenLastCalledWith (
14111413 expect . objectContaining ( {
14121414 detail : {
14131415 expanded : true ,
14141416 record : treeDataSource . list [ 1 ] . student [ 2 ] ,
14151417 } ,
14161418 } )
14171419 ) ;
1418- expect ( onExpandedRowsChange ) . lastCalledWith (
1420+ expect ( onExpandedRowsChange ) . toHaveBeenLastCalledWith (
14191421 expect . objectContaining ( {
14201422 detail : [
14211423 treeDataSource . list [ 1 ] . key ,
@@ -1465,15 +1467,15 @@ describe("expandable", () => {
14651467 expect (
14661468 element . shadowRoot ?. querySelectorAll ( "tbody .ant-table-row" ) . length
14671469 ) . toBe ( treeDataSource . list . length + treeDataSource . list [ 1 ] . student . length ) ;
1468- expect ( onRowExpand ) . lastCalledWith (
1470+ expect ( onRowExpand ) . toHaveBeenLastCalledWith (
14691471 expect . objectContaining ( {
14701472 detail : {
14711473 expanded : false ,
14721474 record : treeDataSource . list [ 1 ] ,
14731475 } ,
14741476 } )
14751477 ) ;
1476- expect ( onExpandedRowsChange ) . lastCalledWith (
1478+ expect ( onExpandedRowsChange ) . toHaveBeenLastCalledWith (
14771479 expect . objectContaining ( {
14781480 detail : getAllKeys ( {
14791481 list : treeDataSource . list ,
0 commit comments