File tree Expand file tree Collapse file tree 3 files changed +59
-3
lines changed
Expand file tree Collapse file tree 3 files changed +59
-3
lines changed Original file line number Diff line number Diff line change 6060 "rc-util" : " ^5.27.1"
6161 },
6262 "devDependencies" : {
63+ "@testing-library/jest-dom" : " ^5.16.5" ,
64+ "@testing-library/react" : " ^12.1.5" ,
6365 "@types/enzyme" : " ^3.10.5" ,
6466 "@types/jest" : " ^28.1.2" ,
6567 "@types/react" : " ^17.0.35" ,
8486 "rc-animate" : " ^3.0.0" ,
8587 "rc-dropdown" : " ~4.0.1" ,
8688 "rc-menu" : " ~9.6.0" ,
87- "rc-test" : " ^7.0.2 " ,
89+ "rc-test" : " ^7.0.14 " ,
8890 "rc-tooltip" : " ^5.2.1" ,
8991 "react" : " ^16.0.0" ,
9092 "react-dnd" : " ^2.5.4" ,
Original file line number Diff line number Diff line change @@ -148,8 +148,8 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
148148 }
149149
150150 // ================ RowSpan & ColSpan =================
151- const mergedColSpan = legacyCellProps ?. colSpan ?? colSpan ?? additionalProps . colSpan ?? 1 ;
152- const mergedRowSpan = legacyCellProps ?. rowSpan ?? rowSpan ?? additionalProps . rowSpan ?? 1 ;
151+ const mergedColSpan = legacyCellProps ?. colSpan ?? additionalProps . colSpan ?? colSpan ?? 1 ;
152+ const mergedRowSpan = legacyCellProps ?. rowSpan ?? additionalProps . rowSpan ?? rowSpan ?? 1 ;
153153
154154 // ====================== Hover =======================
155155 const [ hovering , onHover ] = useHoverState ( index , mergedRowSpan ) ;
Original file line number Diff line number Diff line change 1+ import { render } from '@testing-library/react' ;
2+ import React from 'react' ;
3+ import Table from '../src' ;
4+
5+ describe ( 'Table.ColSpan' , ( ) => {
6+ it ( 'hover the tree table' , ( ) => {
7+ const { container } = render (
8+ < Table
9+ columns = { [
10+ {
11+ title : 'Parent' ,
12+ key : 'parent' ,
13+ children : [
14+ {
15+ title : 'name' ,
16+ key : 'name' ,
17+ dataIndex : 'name' ,
18+ onHeaderCell : ( ) => ( {
19+ colSpan : 2 ,
20+ } ) ,
21+ } ,
22+ {
23+ title : 'age' ,
24+ key : 'age' ,
25+ dataIndex : 'age' ,
26+ onHeaderCell : ( ) => ( { colSpan : 0 } ) ,
27+ } ,
28+ ] ,
29+ } ,
30+ ] }
31+ data = { [
32+ {
33+ key : '1' ,
34+ name : 'Little' ,
35+ age : 2 ,
36+ } ,
37+ ] }
38+ /> ,
39+ ) ;
40+
41+ // 2 rows
42+ expect ( container . querySelector ( 'thead' ) . querySelectorAll ( 'tr' ) ) . toHaveLength ( 2 ) ;
43+
44+ // one cell
45+ const lastTr = container . querySelector ( 'thead' ) . querySelectorAll ( 'tr' ) [ 1 ] ;
46+ expect ( lastTr . querySelectorAll ( 'th' ) ) . toHaveLength ( 1 ) ;
47+ expect ( lastTr . querySelector ( 'th' ) ) . toHaveAttribute ( 'colSpan' , '2' ) ;
48+
49+ // Data 2 cells
50+ expect (
51+ container . querySelector ( 'tbody' ) . querySelectorAll ( 'tr' ) [ 0 ] . querySelectorAll ( 'td' ) ,
52+ ) . toHaveLength ( 2 ) ;
53+ } ) ;
54+ } ) ;
You can’t perform that action at this time.
0 commit comments