Skip to content

Commit

Permalink
MAT-6819_multiPopulationsWorkSheet resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaLiu8 committed Apr 4, 2024
2 parents 5793fbd + 75a3011 commit 73efde0
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/auth/auth.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,44 @@ describe('AuthGuard', () => {
expect(e.message).toBe('Token not present');
}
});

it('should throw UnauthorizedException without Authorization in header', async () => {
const mockExecutionContext = createMock<ExecutionContext>();
expect(mockExecutionContext.switchToHttp()).toBeDefined();

mockExecutionContext.switchToHttp = jest.fn().mockResolvedValue({
getRequest: () => ({
originalUrl: '/',
method: 'GET',
params: undefined,
query: undefined,
body: undefined,
}),
getResponse: () => ({
statusCode: 200,
}),
});

jest
.spyOn(mockExecutionContext.switchToHttp(), 'getRequest')
.mockImplementation(() => {
return {
originalUrl: '/',
method: 'GET',
params: undefined,
query: undefined,
body: undefined,
headers: {
authorize:
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.kcPmFlSUdC9LvuMufomQepInu3GwbBKKct49e2dxyrI',
},
} as unknown as Request;
});

try {
await guard.canActivate(mockExecutionContext);
} catch (e) {
expect(e.message).toBe('Token not present');
}
});
});
55 changes: 55 additions & 0 deletions src/services/export.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,42 @@ describe('ExcelService', () => {
},
],
},
{
testCaseId: 'testCaseId2',
populations: [
{
name: 'initialPopulation',
expected: 2,
actual: 2,
pass: true,
},
],
notes: '',
last: 'testSeries2',
first: 'testTitle2',
birthdate: '11/12/1972',
expired: '',
deathdate: '',
ethnicity: 'Hispanic or Latino',
race: 'Other Race',
gender: 'Female',
definitions: [
{
logic: 'define "Denominator":\n "Initial Population"',
actual: 'UNHIT',
},
],
functions: [
{
logic: 'HospitalizationWithObservation',
actual: 'FUNCTION',
},
{
logic: 'NormalizeInterval',
actual: 'FUNCTION',
},
],
},
],
};
beforeEach(() => {
Expand Down Expand Up @@ -202,6 +238,25 @@ describe('ExcelService', () => {
expect(worksheet.getCell(3, 12).value).toBe('UNHIT');
expect(worksheet.getCell(3, 13).value).toBe('FUNCTION');
expect(worksheet.getCell(3, 14).value).toBe('FUNCTION');
//failed test test cases font color is red
expect(worksheet.getRow(3).font.color.argb).toBe('ff0000');

expect(worksheet.getCell(4, 1).value).toBe(2);
expect(worksheet.getCell(4, 2).value).toBe(2);
expect(worksheet.getCell(4, 3).value).toBe('');
expect(worksheet.getCell(4, 4).value).toBe('testSeries2');
expect(worksheet.getCell(4, 5).value).toBe('testTitle2');
expect(worksheet.getCell(4, 6).value).toBe('11/12/1972');
expect(worksheet.getCell(4, 7).value).toBe('FALSE');
expect(worksheet.getCell(4, 8).value).toBe('');
expect(worksheet.getCell(4, 9).value).toBe('Hispanic or Latino');
expect(worksheet.getCell(4, 10).value).toBe('Other Race');
expect(worksheet.getCell(4, 11).value).toBe('Female');
expect(worksheet.getCell(4, 12).value).toBe('UNHIT');
expect(worksheet.getCell(4, 13).value).toBe('FUNCTION');
expect(worksheet.getCell(4, 14).value).toBe('FUNCTION');
//success test test cases font color is not red (undefined)
expect(worksheet.getRow(4).font).toBe(undefined);
});

it('test generateXlsx', async () => {
Expand Down
1 change: 1 addition & 0 deletions src/services/export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class ExportService {
testCasesData.push(testCaseData);
firstRow = firstRowData;
headerRow = headerRowData;
index += 1;
},
);
this.populateFirstRow(worksheet, firstRow);
Expand Down

0 comments on commit 73efde0

Please sign in to comment.