title: Unit test: simulate the click event of child component in parent using enzyme
body: <p>I have a parent component and a child component which is just a "label" element. When i click the child element, i need to call the function in parent component. I expect it to be called but the state doesnt change and when i saw the coverage file the function isnt being called.</p>
  
  <p>**Updated:**The code works for development. It's just the unit test that fails.</p>
  
  <p>Here is my parent component</p>
  
  <p>parent.js</p>
  
  <pre><code>export default class Parent extends Component {
    constructor(props) {
     super(props)
     this.state={clickedChild: false}
     this.handleChildClick = this.handleChildClick.bind(this)
    }
  
    handleChildClick(index) {
      this.setState({clickedChild:true})
    }
  
    render(){
     const self = this
     return(
      const items = [{'id':1,'text':'hello'},{'id':2,'text':'world'}]
       &lt;div&gt;
         {items.map(function(item,index){
           return &lt;ChildComponent onChildClick ={ self.handleChildClick.bind(null,index)} childItem={item} /&gt;
         })}
       &lt;/div&gt;
     )}
  }
  </code></pre>
  
  <p>child component</p>
  
  <pre><code>export default class ChildComponent extends Component {
      constructor(props) { super(props)}
  
     render(){
      return(
       &lt;label onClick={this.props.onChildClick}&gt;{this.props.childItem.text} &lt;/label&gt;
      )
     }
  }
  </code></pre>
  
  <p>unit test </p>
  
  <pre><code>import chai from 'chai'
  import React from 'react'
  import ReactDOM from 'react-dom'
  import { mount, shallow } from 'enzyme';
  import sinon from 'sinon'
  import Parent from '../Parent'
  import ChildComponent from '../ChildComponent'
  
  
  let expect = chai.expect
     describe('check click event on child()',()=&gt;{
        it('clicking menu item',()=&gt;{
            const items = [{'id':1,'text':'hello'},{'id':2,'text':'world'}]
            const wrapper = mount(&lt;Parent items={items} /&gt;)
            console.log(wrapper.state('clickedChild')) // prints false
            wrapper.find(ChildComponent).last().simulate('click',1)
            // tried the following
            // wrapper.find(ChildComponent).last().simulate('click')
  
            console.log(wrapper.state('clickedChild'))  // still prints false
          })
      })
  </code></pre>