title: Unit test new Blob Enzyme for node env
body: <p>I'm trying to test with Enzyme some download function, my test runs in node env. But the method I use is actually dom api, and how to test it in node env. In my code I use <code>DOM API</code> like <code>windows.URL.revokeObjectURL</code>, <code>document.createElement('a')</code> <code>window.URL.createObjectURL(new Blob([encodeWorkBook(wbout)], {type:'application/octet-stream'}))</code></p>
  
  <pre><code>   export const download = (url, name) =&gt; {
      let a = document.createElement('a')
      a.href = url
      a.download = name
      a.click()
      window.URL.revokeObjectURL(url)
  }
  
  export const encodeWorkBook = string =&gt; {
      const buf = new ArrayBuffer(string.length)
      const unicodeArray = new Uint8Array(buf)
  
      for (let i=0; i !== string.length; ++i)
          unicodeArray[i] = string.charCodeAt(i) &amp; 0xFF
  
      return unicodeArray
  }
  
  export default (data, sheetName, bookType = OutPutFormats.xlsx) =&gt; {
      import('xlsx').then(XLSX =&gt; {
          const ws = XLSX.utils.json_to_sheet(data, {cellStyles: true})
          const wb = XLSX.utils.book_new()
          XLSX.utils.book_append_sheet(wb, ws, sheetName)
  
          const wbout = XLSX.write(wb, {bookType, bookSST:true, type: 'binary'})
  
          /* creates a DOMString containing a URL */
  
          let url = window.URL.createObjectURL(new Blob([encodeWorkBook(wbout)], {type:'application/octet-stream'}))
  
          download(url, `import.${bookType}`)
      })
  }
  </code></pre>