update at 2026-02-14 11:16:40

This commit is contained in:
douboer@gmail.com
2026-02-14 11:16:40 +08:00
parent 78896060b2
commit 3d9558508a
3 changed files with 67 additions and 3 deletions

View File

@@ -87,4 +87,20 @@ describe('miniapp utils sankey', () => {
expect(table.headers).toEqual(['人數']);
expect(table.rows).toEqual([['张三']]);
});
it('文件名后缀缺失时,仍可根据二进制魔数识别 xlsx', () => {
const sheet = XLSX.utils.aoa_to_sheet([
['source', 'target', 'value'],
['A', 'B', 1]
]);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, sheet, 'S1');
const buffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'buffer' });
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
const table = parseTableByFileName('upload.bin', arrayBuffer);
expect(table.headers).toEqual(['source', 'target', 'value']);
expect(table.rows).toEqual([['A', 'B', '1']]);
});
});