@@ -441,7 +441,7 @@ describe('Table', () => {
441441 expect ( wrapper ) . toMatchSnapshot ( ) ;
442442 } ) ;
443443
444- it ( 'onRow' , ( ) => {
444+ it ( 'renders onRow correctly ' , ( ) => {
445445 const onRow = ( record , index ) => ( {
446446 id : `row-${ record . key } ` ,
447447 index,
@@ -451,6 +451,43 @@ describe('Table', () => {
451451 expect ( wrapper . find ( 'tbody tr' ) ) . toMatchSnapshot ( ) ;
452452 } ) ;
453453
454+ it ( 'renders column.onCell correctly' , ( ) => {
455+ const onCell = ( record ) => ( {
456+ id : `cell-${ record . name } ` ,
457+ } ) ;
458+ const columns = [
459+ { title : 'Name' , dataIndex : 'name' , key : 'name' , onCell } ,
460+ ] ;
461+ const wrapper = render ( createTable ( { columns } ) ) ;
462+
463+ expect ( wrapper . find ( 'tbody td' ) ) . toMatchSnapshot ( ) ;
464+ } ) ;
465+
466+ it ( 'renders onHeaderRow correctly' , ( ) => {
467+ const onHeaderRow = jest . fn ( ( columns , index ) => ( {
468+ id : `header-row-${ index } ` ,
469+ } ) ) ;
470+ const wrapper = render ( createTable ( { onHeaderRow } ) ) ;
471+
472+ expect ( wrapper . find ( 'thead tr' ) ) . toMatchSnapshot ( ) ;
473+ expect ( onHeaderRow ) . toBeCalledWith (
474+ [ { title : 'Name' , dataIndex : 'name' , key : 'name' } ] ,
475+ 0 ,
476+ ) ;
477+ } ) ;
478+
479+ it ( 'renders column.onHeaderCell' , ( ) => {
480+ const onHeaderCell = ( column ) => ( {
481+ id : `header-cell-${ column . key } ` ,
482+ } ) ;
483+ const columns = [
484+ { title : 'Name' , dataIndex : 'name' , key : 'name' , onHeaderCell } ,
485+ ] ;
486+ const wrapper = render ( createTable ( { columns } ) ) ;
487+
488+ expect ( wrapper . find ( 'thead th' ) ) . toMatchSnapshot ( ) ;
489+ } ) ;
490+
454491 describe ( 'custom components' , ( ) => {
455492 const MyTable = ( props ) => < table name = "my-table" { ...props } /> ;
456493 const HeaderWrapper = ( props ) => < thead name = "my-header-wrapper" { ...props } /> ;
0 commit comments