File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 11# CHANGELOG
22
3+ ## v1.1.0 (TBA)
4+
5+ ### New Features
6+
7+ * [ #72 ] : Add the node that triggers ` onCheck ` or ` onExpand ` as a second parameter
8+
39## [ v1.0.2] ( https://github.com/jakezatecky/react-checkbox-tree/compare/v1.0.1...v1.0.2 ) (2017-10-24)
410
511### Bug Fixes
Original file line number Diff line number Diff line change @@ -206,4 +206,61 @@ describe('<CheckboxTree />', () => {
206206 } ) ;
207207 } ) ;
208208 } ) ;
209+
210+ describe ( 'onCheck' , ( ) => {
211+ it ( 'should pass the node toggled as the second parameter' , ( ) => {
212+ let actualNode = null ;
213+
214+ const wrapper = mount (
215+ < CheckboxTree
216+ checked = { [ ] }
217+ nodes = { [
218+ {
219+ value : 'jupiter' ,
220+ label : 'Jupiter' ,
221+ children : [
222+ { value : 'io' , label : 'Io' } ,
223+ { value : 'europa' , label : 'Europa' } ,
224+ ] ,
225+ } ,
226+ ] }
227+ onCheck = { ( checked , node ) => {
228+ actualNode = node ;
229+ } }
230+ /> ,
231+ ) ;
232+
233+ wrapper . find ( 'TreeNode input[type="checkbox"]' ) . simulate ( 'change' ) ;
234+ assert . equal ( 'jupiter' , actualNode . value ) ;
235+ } ) ;
236+ } ) ;
237+
238+
239+ describe ( 'onExpand' , ( ) => {
240+ it ( 'should pass the node toggled as the second parameter' , ( ) => {
241+ let actualNode = null ;
242+
243+ const wrapper = mount (
244+ < CheckboxTree
245+ checked = { [ ] }
246+ nodes = { [
247+ {
248+ value : 'jupiter' ,
249+ label : 'Jupiter' ,
250+ children : [
251+ { value : 'io' , label : 'Io' } ,
252+ { value : 'europa' , label : 'Europa' } ,
253+ ] ,
254+ } ,
255+ ] }
256+ onExpand = { ( expanded , node ) => {
257+ actualNode = node ;
258+ } }
259+ /> ,
260+ ) ;
261+
262+ wrapper . find ( 'TreeNode .rct-collapse-btn' ) . simulate ( 'click' ) ;
263+ assert . equal ( 'jupiter' , actualNode . value ) ;
264+ } ) ;
265+ } ) ;
209266} ) ;
You can’t perform that action at this time.
0 commit comments