title: How to test below component in React using JEST
body: <p>I created a component for Download File which takes some props and download the file on button click, its has two function which call showLoader and HideLoader</p>
  
  <p><strong>Component</strong>: Below is component code which takes some props and created a Download button on click that user download file.</p>
  
  <pre><code>import React from 'react'
  import FileSaver from 'file-saver'
  import axios from 'axios'
  
  const DownloadFile = (props) =&gt; {
  
    const { url, title, callShowLoader, callHideLoader } = props
  
    const callDownloadFile = () =&gt; {
      callShowLoader()
      axios.get(url, { responseType: 'blob' }).then(res =&gt; {
        const fileName = res.headers['content-disposition'].match(/\"(.*?)"/)
        const fileToDownload = new Blob([res.data], {type: 'application/vnd.ms-excel;charset=charset=utf-8'})
        FileSaver.saveAs(fileToDownload, fileName[1])
        callHideLoader()
      })
    }
  
    return (&lt;button className='mck-button-primary' title={title} onClick={e =&gt; callDownloadFile()}&gt;
              &lt;span className={"mck-icon__download mck-icon-no-pad"} /&gt;
            &lt;/button&gt;)
  }
  
  export default DownloadFile
  </code></pre>
  
  <p><strong>Test</strong> Here i am testing the component, not able to test when user clicks on button for download, its giving callShowLoader is not function error</p>
  
  <pre><code>import React from 'react'
  import { shallow, mount } from 'enzyme'
  import DownloadFile from '../index.js'
  import toJson from 'enzyme-to-json'
  import axios from 'axios'
  
  describe('&lt;DownloadFile /&gt;', () =&gt; {
    const props = {
      callHideLoader: jest.fn(),
      callShowLoader: jest.fn(),
      title: 'Download Excel Report'
    }
  
    it('should render button title properly', () =&gt; {
      const wrapper = shallow(&lt;DownloadFile {...props}/&gt;)
      expect(wrapper.find('button').prop('title')).toEqual(props.title)
    })
  
    it('should call download file', () =&gt; {
      const callShowLoader = jest.fn()
      const wrapper = shallow(&lt;DownloadFile {...props} callShowLoader={callShowLoader} /&gt;)
      wrapper.find('button').simulate('click')
      expect(callShowLoader).toHaveBeenCalled()
    })
  
    it('should match intial layout', () =&gt; {
      const wrapper = shallow(&lt;DownloadFile {...props}/&gt;)
      expect(wrapper.getElements()).toMatchSnapshot()
    })
  })
  </code></pre>