1
- import React from 'react' ;
2
1
import { mount } from 'enzyme' ;
3
- import { act } from 'react-dom/test-utils' ;
4
- import { resetWarned } from 'rc-util/lib/warning' ;
5
2
import { spyElementPrototype } from 'rc-util/lib/test/domHook' ;
3
+ import { resetWarned } from 'rc-util/lib/warning' ;
4
+ import React from 'react' ;
5
+ import { act } from 'react-dom/test-utils' ;
6
6
import Table from '../src' ;
7
7
8
8
describe ( 'Table.Expand' , ( ) => {
@@ -22,7 +22,7 @@ describe('Table.Expand', () => {
22
22
23
23
it ( 'renders expand row correctly' , ( ) => {
24
24
resetWarned ( ) ;
25
- const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
25
+ const errorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
26
26
const wrapper = mount ( createTable ( { expandedRowRender } ) ) ;
27
27
expect ( wrapper . find ( 'tbody tr' ) ) . toHaveLength ( 2 ) ;
28
28
expect ( errorSpy ) . toHaveBeenCalledWith (
@@ -32,7 +32,7 @@ describe('Table.Expand', () => {
32
32
} ) ;
33
33
34
34
it ( 'pass proper parameters to expandedRowRender' , ( ) => {
35
- const rowRender = jest . fn ( ( ) => < div > expanded row</ div > ) ;
35
+ const rowRender = vi . fn ( ( ) => < div > expanded row</ div > ) ;
36
36
const expandableProps = props => ( { expandable : { expandedRowRender : rowRender , ...props } } ) ;
37
37
const wrapper = mount ( createTable ( expandableProps ( ) ) ) ;
38
38
wrapper . setProps ( expandableProps ( { expandedRowKeys : [ 0 ] } ) ) ;
@@ -232,7 +232,7 @@ describe('Table.Expand', () => {
232
232
describe ( 'config expand column index' , ( ) => {
233
233
it ( 'not show EXPAND_COLUMN if expandable is false' , ( ) => {
234
234
resetWarned ( ) ;
235
- const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
235
+ const errorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
236
236
237
237
const wrapper = mount (
238
238
createTable ( {
@@ -250,7 +250,7 @@ describe('Table.Expand', () => {
250
250
251
251
it ( 'renders expand icon to the specify column' , ( ) => {
252
252
resetWarned ( ) ;
253
- const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
253
+ const errorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
254
254
255
255
const wrapper = mount (
256
256
createTable ( {
@@ -287,7 +287,7 @@ describe('Table.Expand', () => {
287
287
288
288
it ( 'de-duplicate of EXPAND_COLUMN' , ( ) => {
289
289
resetWarned ( ) ;
290
- const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
290
+ const errorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
291
291
292
292
const wrapper = mount (
293
293
createTable ( {
@@ -400,7 +400,7 @@ describe('Table.Expand', () => {
400
400
} ) ;
401
401
402
402
it ( 'renders expend row class correctly' , ( ) => {
403
- const expandedRowClassName = jest . fn ( ) . mockReturnValue ( 'expand-row-test-class-name' ) ;
403
+ const expandedRowClassName = vi . fn ( ) . mockReturnValue ( 'expand-row-test-class-name' ) ;
404
404
const wrapper = mount (
405
405
createTable ( {
406
406
expandable : {
@@ -431,7 +431,7 @@ describe('Table.Expand', () => {
431
431
} ) ;
432
432
433
433
it ( 'fires expand change event' , ( ) => {
434
- const onExpand = jest . fn ( ) ;
434
+ const onExpand = vi . fn ( ) ;
435
435
const wrapper = mount (
436
436
createTable ( {
437
437
expandable : {
@@ -448,7 +448,7 @@ describe('Table.Expand', () => {
448
448
} ) ;
449
449
450
450
it ( 'fires onExpandedRowsChange event' , ( ) => {
451
- const onExpandedRowsChange = jest . fn ( ) ;
451
+ const onExpandedRowsChange = vi . fn ( ) ;
452
452
const wrapper = mount (
453
453
createTable ( {
454
454
expandedRowRender,
@@ -473,7 +473,7 @@ describe('Table.Expand', () => {
473
473
} ) ;
474
474
475
475
it ( 'expandRowByClick' , ( ) => {
476
- const onExpand = jest . fn ( ) ;
476
+ const onExpand = vi . fn ( ) ;
477
477
const wrapper = mount (
478
478
createTable ( {
479
479
expandable : {
@@ -533,7 +533,7 @@ describe('Table.Expand', () => {
533
533
// https://github.com/ant-design/ant-design/issues/23894
534
534
it ( 'should be collapsible when use `expandIcon` & `expandRowByClick`' , ( ) => {
535
535
const data = [ { key : 0 , name : 'Lucy' , age : 27 } ] ;
536
- const onExpand = jest . fn ( ) ;
536
+ const onExpand = vi . fn ( ) ;
537
537
const wrapper = mount (
538
538
createTable ( {
539
539
expandable : {
@@ -561,7 +561,7 @@ describe('Table.Expand', () => {
561
561
// https://github.com/ant-design/ant-design/issues/23894
562
562
it ( 'should be collapsible when `expandRowByClick` without custom `expandIcon`' , ( ) => {
563
563
const data = [ { key : 0 , name : 'Lucy' , age : 27 } ] ;
564
- const onExpand = jest . fn ( ) ;
564
+ const onExpand = vi . fn ( ) ;
565
565
const wrapper = mount (
566
566
createTable ( {
567
567
expandable : {
@@ -582,7 +582,7 @@ describe('Table.Expand', () => {
582
582
583
583
it ( 'should be collapsible when `expandRowByClick` with custom `expandIcon` and event.stopPropagation' , ( ) => {
584
584
const data = [ { key : 0 , name : 'Lucy' , age : 27 } ] ;
585
- const onExpand = jest . fn ( ) ;
585
+ const onExpand = vi . fn ( ) ;
586
586
const wrapper = mount (
587
587
createTable ( {
588
588
expandable : {
@@ -612,7 +612,7 @@ describe('Table.Expand', () => {
612
612
613
613
it ( 'support invalid expandIcon' , ( ) => {
614
614
const data = [ { key : 0 , name : 'Lucy' , age : 27 } ] ;
615
- const onExpand = jest . fn ( ) ;
615
+ const onExpand = vi . fn ( ) ;
616
616
const wrapper = mount (
617
617
createTable ( {
618
618
expandable : {
@@ -629,7 +629,7 @@ describe('Table.Expand', () => {
629
629
630
630
it ( 'warning for use `expandedRowRender` and nested table in the same time' , ( ) => {
631
631
resetWarned ( ) ;
632
- const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
632
+ const errorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
633
633
mount ( createTable ( { expandedRowRender, data : [ { children : [ ] } ] } ) ) ;
634
634
expect ( errorSpy ) . toHaveBeenCalledWith (
635
635
'Warning: `expandedRowRender` should not use with nested Table' ,
0 commit comments