title: Jest Unit testing onClick event
body: <p>I have a Component and want to unit test it with react jest... I want to test onClick event.. I've tried many cases but they don't cover onClick statement</p>
  <p><strong>This my Component</strong></p>
  <pre><code>export default class HeaderCreate extends Component {
  
    render() {
      const { name, description, closeRightSection } = this.props;
      return (
        &lt;div className=&quot;header&quot;&gt;
          &lt;h1 className=&quot;header-text&quot; title={name} data-testid=&quot;header&quot;&gt;{name}&lt;/h1&gt;
          &lt;p data-testid= &quot;description-para&quot;&gt;{description}&lt;/p&gt;
  
          &lt;Tooltip title=&quot;Close Section&quot;&gt;
            &lt;div className=&quot;icon-close&quot;&gt;
              &lt;i className=&quot;material-icons&quot; onClick={() =&gt; closeRightSection()} data-testid=&quot;id&quot;&gt;close&lt;/i&gt;
            &lt;/div&gt;
          &lt;/Tooltip&gt;
        &lt;/div&gt;
      )
    }
  }; 
  </code></pre>
  <p><strong>This is my test.js</strong></p>
  <pre><code>import React from 'react'
  import { render } from &quot;@testing-library/react&quot;;
  
  import HeaderCreate from '../components/createHeader';
  
  test(&quot;render header correctly&quot;, () =&gt; {
      const { getByTestId } = render(&lt;HeaderCreate name=&quot;My Name is Test&quot;&gt;&lt;/HeaderCreate&gt;);
      expect(getByTestId('header').textContent).toBe('My Name is Test')
  });
  
  test(&quot;render Description Paragraph correctly&quot;, () =&gt; {
      const { getByTestId } = render(&lt;HeaderCreate description=&quot;Hi I am Description box&quot;&gt;&lt;/HeaderCreate&gt;);
      expect(getByTestId('description-para').textContent).toBe('Hi I am Description box')
  });
  
  test(&quot;render close tooltip correctly&quot;, () =&gt; {
      const { getByTestId } = render(&lt;HeaderCreate closeRightSection=&quot;&quot;&gt;&lt;/HeaderCreate&gt;);
      expect(getByTestId('id')).toBeTruthy();
  }); 
  </code></pre>
  <p>In Coverage it is show all onClick event as statement not covered.. and statement coverage is 66.67%. How can I make it 100%..? I am new to Reactjs. So I am Confused what to do now.. I have search on various place but didn't got any solution. Please suggest me where I am wrong</p>
  <p>Thanks in advance</p>