Skip to content

Commit

Permalink
MAT 6727 refactored code and renamed function
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-prateekkeerthi committed Mar 19, 2024
1 parent 5785bda commit 8833bfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/controllers/export.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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 () => {
Expand All @@ -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);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/export.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8833bfa

Please sign in to comment.