@@ -91,6 +91,32 @@ describe('behavior', () => {
9191 } ) ;
9292 } ) ;
9393 } ) ;
94+ describe ( 'row selection' , ( ) => {
95+ it ( 'should not toggle row selection if onClick handled the action' , ( ) => {
96+ const clickedColumn = { id : 'editButton' } ;
97+ const toggleSelection = jest . fn ( ) ;
98+ const propsCreator = _getTdProps ( jest . fn ( ) , jest . fn ( ) , jest . fn ( ) , jest . fn ( ) ) ;
99+ const props = propsCreator ( { } , { original : { } } , clickedColumn , { } , toggleSelection ) ;
100+ props . onClick ( { } , jest . fn ( ) ) ;
101+ expect ( toggleSelection ) . not . toBeCalled ( ) ;
102+ } ) ;
103+ it ( 'should toggle row selection if onClick did not handle the action' , ( ) => {
104+ const clickedColumn = { id : 'unrecognized' } ;
105+ const toggleSelection = jest . fn ( ) ;
106+ const propsCreator = _getTdProps ( jest . fn ( ) , jest . fn ( ) , jest . fn ( ) , jest . fn ( ) ) ;
107+ const props = propsCreator ( { } , { original : { } } , clickedColumn , { } , toggleSelection ) ;
108+ props . onClick ( { } , jest . fn ( ) ) ;
109+ expect ( toggleSelection ) . toBeCalled ( ) ;
110+ } ) ;
111+ it ( 'should not toggle row selection if onClick did not handle the action and the column is an Expander' , ( ) => {
112+ const clickedColumn = { id : 'unrecognized' , Expander : jest . fn ( ) } ;
113+ const toggleSelection = jest . fn ( ) ;
114+ const propsCreator = _getTdProps ( jest . fn ( ) , jest . fn ( ) , jest . fn ( ) , jest . fn ( ) ) ;
115+ const props = propsCreator ( { } , { original : { } } , clickedColumn , { } , toggleSelection ) ;
116+ props . onClick ( { } , jest . fn ( ) ) ;
117+ expect ( toggleSelection ) . not . toBeCalled ( ) ;
118+ } ) ;
119+ } ) ;
94120 describe ( 'handleOriginal' , ( ) => {
95121 it ( 'should fall back to handleOriginal in other cases' , ( ) => {
96122 const clickedColumn = {
@@ -105,7 +131,7 @@ describe('behavior', () => {
105131 } ;
106132 const handleOriginal = jest . fn ( ) ;
107133 const propsCreator = _getTdProps ( jest . fn ( ) , jest . fn ( ) , jest . fn ( ) , jest . fn ( ) ) ;
108- const props = propsCreator ( { } , clickedRow , clickedColumn ) ;
134+ const props = propsCreator ( { } , clickedRow , clickedColumn , { } , jest . fn ( ) ) ;
109135 props . onClick ( { } , handleOriginal ) ;
110136 expect ( handleOriginal ) . toHaveBeenCalledTimes ( 1 ) ;
111137 } ) ;
@@ -121,7 +147,7 @@ describe('behavior', () => {
121147 }
122148 } ;
123149 const propsCreator = _getTdProps ( jest . fn ( ) , jest . fn ( ) , jest . fn ( ) , jest . fn ( ) ) ;
124- const props = propsCreator ( { } , clickedRow , clickedColumn ) ;
150+ const props = propsCreator ( { } , clickedRow , clickedColumn , { } , jest . fn ( ) ) ;
125151 props . onClick ( { } , null ) ;
126152 expect ( true ) . toBe ( true ) ;
127153 } ) ;
0 commit comments