diff --git a/src/controllers/export.controller.spec.ts b/src/controllers/export.controller.spec.ts index 33f0fee..eb6a08e 100644 --- a/src/controllers/export.controller.spec.ts +++ b/src/controllers/export.controller.spec.ts @@ -27,7 +27,7 @@ describe('exportController', () => { const response: Response = httpMocks.createResponse() as Response; - await expect(exportController.getFile(response)).toBeDefined(); + await expect(exportController.getExcelFile(response)).toBeDefined(); //expect(res.statusCode).toEqual(200); }); @@ -39,7 +39,7 @@ describe('exportController', () => { header: jest.fn(), send: jest.fn(), }; - await exportController.getFile(res as Response); + await exportController.getExcelFile(res as Response); expect(exportService.generateXlsx).toHaveBeenCalledTimes(1); }); it('should send the generated Excel file as the response', async () => { @@ -51,7 +51,7 @@ describe('exportController', () => { header: jest.fn(), send: jest.fn(), }; - await exportController.getFile(res as Response); + await exportController.getExcelFile(res as Response); expect(res.send).toHaveBeenCalledWith(mockedExcelBuffer); }); }); diff --git a/src/controllers/export.controller.ts b/src/controllers/export.controller.ts index 30ba77d..8470e26 100644 --- a/src/controllers/export.controller.ts +++ b/src/controllers/export.controller.ts @@ -4,17 +4,17 @@ import { ExportService } from '../services/export.service'; import { AuthGuard } from '../auth/auth.guard'; @Controller('excel') +@UseGuards(AuthGuard) export class ExportController { constructor(private readonly exportService: ExportService) {} - @UseGuards(AuthGuard) @Get() @Header( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ) @Header('Content-Disposition', 'attachment; filename="exampleWorkbook.xlsx"') - async getFile(@Res() res: Response) { + async getExcelFile(@Res() res: Response) { const buffer = await this.exportService.generateXlsx(); res.send(buffer); }