0

私はインポートをsinon jsでスタブしようとしていますが、実際にそれを行う方法は import XLSX from 'xlsx' beforeEach(() => sinon.stub(sheetJS).resolve({}))- 私にとってはうまくいきません。resolve is not a function

 export default (data, sheetName, bookType = OutputFormats.xlsx) =>
import('xlsx').then(XLSX => {
    /* create worksheet from data */
    const ws = XLSX.utils.json_to_sheet(data, {cellStyles: true})

    /* create new workbook and add worksheet */
    const wb = XLSX.utils.book_new()
    XLSX.utils.book_append_sheet(wb, ws, sheetName)

    /* generate with and height of cells in .xlsx file */
    const wscols = Object.keys(data[0]).map(key => key = {wch: key.length + 2})

    const wsrows = new Array(data.length).fill({hpt: 24})
    ws['!cols'] = wscols
    ws['!rows'] = wsrows

    /* write a workbook */
    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'}))

    file.download(url, `import.${bookType}`)
})
4

1 に答える 1