title: Jest: unit testing creation of an excel document after http call Blob response
body: <p>I am working on a react application, using Jest</p>
  
  <p>I have to download an excel that I get as a Blob from an HTTP call 
  I have to respect a coverage of 90% unit tests, and I am in trouble with this portion of code:</p>
  
  <pre><code>downloadExcel = () =&gt; {
    templateService.getTemplate().then(
      response =&gt; {
        const url = window.URL.createObjectURL(new Blob([response.data]));
        const link = document.createElement("a");
        link.href = url;
        link.setAttribute("download", "Project_register_template_PMB.xlsx");
        document.body.appendChild(link);
        link.click();
      },
      error =&gt; {
        this.setState({
          errors: { api: `API error:${error}, please contact an administrator` }
        });
      }
    );
  };
  </code></pre>
  
  <p>Here is my template service: </p>
  
  <pre><code>const getTemplate = async () =&gt; {
    const options = {
      responseType: "blob",
      headers: handleHeaders()
    };
    return await axios.get(downloadUrl, options).catch(handleResponse);
  };
  
  const uploadTemplate = async formData =&gt; {
    return await axios.post(uploadUrl, formData, { headers: handleHeaders() });
  };
  
  export const templateService = { getTemplate, uploadTemplate };
  </code></pre>
  
  <p>I am a very recent react developer and maybe I am doing it wrong, I would be glad to change my code by following any piece of advice</p>
  
  <p>Thank you for your help</p>