@@ -4,19 +4,22 @@ import { render, mount } from 'enzyme';
44import Table from '../src' ;
55
66describe ( 'Table.expand' , ( ) => {
7- const columns = [
7+ const expandedRowRender = ( ) => < p > extra data</ p > ;
8+
9+ const sampleColumns = [
810 { title : 'Name' , dataIndex : 'name' , key : 'name' } ,
911 { title : 'Age' , dataIndex : 'age' , key : 'age' } ,
1012 ] ;
11- const data = [
13+
14+ const sampleData = [
1215 { key : 0 , name : 'Lucy' , age : 27 } ,
1316 { key : 1 , name : 'Jack' , age : 28 } ,
1417 ] ;
15- const expandedRowRender = ( ) => < p > extra data </ p > ;
18+
1619 const createTable = ( props ) => (
1720 < Table
18- columns = { columns }
19- data = { data }
21+ columns = { sampleColumns }
22+ data = { sampleData }
2023 { ...props }
2124 />
2225 ) ;
@@ -27,13 +30,27 @@ describe('Table.expand', () => {
2730 } ) ;
2831
2932 it ( 'renders tree row correctly' , ( ) => {
30- const localData = [
33+ const data = [
3134 { key : 0 , name : 'Lucy' , age : 27 , children : [
3235 { key : 2 , name : 'Jim' , age : 1 } ,
3336 ] } ,
3437 { key : 1 , name : 'Jack' , age : 28 } ,
3538 ] ;
36- const wrapper = render ( createTable ( { data : localData } ) ) ;
39+ const wrapper = render ( createTable ( { data } ) ) ;
40+ expect ( wrapper ) . toMatchSnapshot ( ) ;
41+ } ) ;
42+
43+ it ( 'renders fixed column correctly' , ( ) => {
44+ const columns = [
45+ { title : 'Name' , dataIndex : 'name' , key : 'name' , fixed : true } ,
46+ { title : 'Age' , dataIndex : 'age' , key : 'age' } ,
47+ { title : 'Gender' , dataIndex : 'gender' , key : 'gender' , fixed : 'right' } ,
48+ ] ;
49+ const data = [
50+ { key : 0 , name : 'Lucy' , age : 27 , gender : 'F' } ,
51+ { key : 1 , name : 'Jack' , age : 28 , gender : 'M' } ,
52+ ] ;
53+ const wrapper = render ( createTable ( { columns, data, expandedRowRender } ) ) ;
3754 expect ( wrapper ) . toMatchSnapshot ( ) ;
3855 } ) ;
3956
@@ -107,7 +124,7 @@ describe('Table.expand', () => {
107124 expandedRowClassName,
108125 } ) ) ;
109126 expect ( wrapper ) . toMatchSnapshot ( ) ;
110- expect ( expandedRowClassName ) . toBeCalledWith ( data [ 0 ] , 0 , 0 ) ;
127+ expect ( expandedRowClassName ) . toBeCalledWith ( sampleData [ 0 ] , 0 , 0 ) ;
111128 } ) ;
112129
113130 it ( 'fires expand change event' , ( ) => {
@@ -117,9 +134,9 @@ describe('Table.expand', () => {
117134 onExpand,
118135 } ) ) ;
119136 wrapper . find ( 'ExpandIcon' ) . first ( ) . simulate ( 'click' ) ;
120- expect ( onExpand ) . toBeCalledWith ( true , data [ 0 ] ) ;
137+ expect ( onExpand ) . toBeCalledWith ( true , sampleData [ 0 ] ) ;
121138 wrapper . find ( 'ExpandIcon' ) . first ( ) . simulate ( 'click' ) ;
122- expect ( onExpand ) . toBeCalledWith ( false , data [ 0 ] ) ;
139+ expect ( onExpand ) . toBeCalledWith ( false , sampleData [ 0 ] ) ;
123140 } ) ;
124141
125142 it ( 'fires onExpandedRowsChange event' , ( ) => {
@@ -145,7 +162,7 @@ describe('Table.expand', () => {
145162 expect ( onExpandedRowsChange ) . toBeCalledWith ( [ 1 ] ) ;
146163 } ) ;
147164
148- fit ( 'expand row by click' , ( ) => {
165+ it ( 'expand row by click' , ( ) => {
149166 const wrapper = mount ( createTable ( { expandedRowRender } ) ) ;
150167 wrapper . find ( 'ExpandIcon' ) . first ( ) . simulate ( 'click' ) ;
151168 expect ( wrapper . render ( ) ) . toMatchSnapshot ( ) ;
0 commit comments