diff --git a/src/data/repositories/ProductExportSpreadsheetRepository.ts b/src/data/repositories/ProductExportSpreadsheetRepository.ts index 315106e..6e387a8 100644 --- a/src/data/repositories/ProductExportSpreadsheetRepository.ts +++ b/src/data/repositories/ProductExportSpreadsheetRepository.ts @@ -42,6 +42,12 @@ export class ProductExportSpreadsheetRepository implements ProductExportReposito ], }; + const wb = this.buildExcelWorkbook(workbook); + + this.saveWorkbook(wb, workbook.name); + } + + private buildExcelWorkbook(workbook: Workbook) { const wb = new ExcelJS.Workbook(); workbook.sheets.forEach(sheet => { @@ -51,7 +57,7 @@ export class ProductExportSpreadsheetRepository implements ProductExportReposito sh.addRows(sheet.rows); }); - this.saveWorkBook(wb, name); + return wb; } private splitProducts(products: Product[]) { @@ -99,7 +105,7 @@ export class ProductExportSpreadsheetRepository implements ProductExportReposito }; } - protected async saveWorkBook(wb: ExcelJS.Workbook, name: string): Promise { + protected async saveWorkbook(wb: ExcelJS.Workbook, name: string): Promise { wb.xlsx.writeFile(name); } } diff --git a/src/data/repositories/__test__/ProductExportSpreadsheetRepositoryTest.ts b/src/data/repositories/__test__/ProductExportSpreadsheetRepositoryTest.ts index f8e30c2..664cf9b 100644 --- a/src/data/repositories/__test__/ProductExportSpreadsheetRepositoryTest.ts +++ b/src/data/repositories/__test__/ProductExportSpreadsheetRepositoryTest.ts @@ -18,7 +18,7 @@ export class ProductExportSpreadsheetRepositoryTest extends ProductExportSpreads wb: ExcelJS.Workbook = new ExcelJS.Workbook(); workBookName = ""; - protected async saveWorkBook(wb: ExcelJS.Workbook, workBookName: string): Promise { + protected async saveWorkbook(wb: ExcelJS.Workbook, workBookName: string): Promise { this.wb = wb; this.workBookName = workBookName; }