Skip to content

Commit 73efde0

Browse files
committed
MAT-6819_multiPopulationsWorkSheet resolve conflicts
2 parents 5793fbd + 75a3011 commit 73efde0

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

src/auth/auth.guard.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,44 @@ describe('AuthGuard', () => {
130130
expect(e.message).toBe('Token not present');
131131
}
132132
});
133+
134+
it('should throw UnauthorizedException without Authorization in header', async () => {
135+
const mockExecutionContext = createMock<ExecutionContext>();
136+
expect(mockExecutionContext.switchToHttp()).toBeDefined();
137+
138+
mockExecutionContext.switchToHttp = jest.fn().mockResolvedValue({
139+
getRequest: () => ({
140+
originalUrl: '/',
141+
method: 'GET',
142+
params: undefined,
143+
query: undefined,
144+
body: undefined,
145+
}),
146+
getResponse: () => ({
147+
statusCode: 200,
148+
}),
149+
});
150+
151+
jest
152+
.spyOn(mockExecutionContext.switchToHttp(), 'getRequest')
153+
.mockImplementation(() => {
154+
return {
155+
originalUrl: '/',
156+
method: 'GET',
157+
params: undefined,
158+
query: undefined,
159+
body: undefined,
160+
headers: {
161+
authorize:
162+
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.kcPmFlSUdC9LvuMufomQepInu3GwbBKKct49e2dxyrI',
163+
},
164+
} as unknown as Request;
165+
});
166+
167+
try {
168+
await guard.canActivate(mockExecutionContext);
169+
} catch (e) {
170+
expect(e.message).toBe('Token not present');
171+
}
172+
});
133173
});

src/services/export.service.spec.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,42 @@ describe('ExcelService', () => {
8282
},
8383
],
8484
},
85+
{
86+
testCaseId: 'testCaseId2',
87+
populations: [
88+
{
89+
name: 'initialPopulation',
90+
expected: 2,
91+
actual: 2,
92+
pass: true,
93+
},
94+
],
95+
notes: '',
96+
last: 'testSeries2',
97+
first: 'testTitle2',
98+
birthdate: '11/12/1972',
99+
expired: '',
100+
deathdate: '',
101+
ethnicity: 'Hispanic or Latino',
102+
race: 'Other Race',
103+
gender: 'Female',
104+
definitions: [
105+
{
106+
logic: 'define "Denominator":\n "Initial Population"',
107+
actual: 'UNHIT',
108+
},
109+
],
110+
functions: [
111+
{
112+
logic: 'HospitalizationWithObservation',
113+
actual: 'FUNCTION',
114+
},
115+
{
116+
logic: 'NormalizeInterval',
117+
actual: 'FUNCTION',
118+
},
119+
],
120+
},
85121
],
86122
};
87123
beforeEach(() => {
@@ -202,6 +238,25 @@ describe('ExcelService', () => {
202238
expect(worksheet.getCell(3, 12).value).toBe('UNHIT');
203239
expect(worksheet.getCell(3, 13).value).toBe('FUNCTION');
204240
expect(worksheet.getCell(3, 14).value).toBe('FUNCTION');
241+
//failed test test cases font color is red
242+
expect(worksheet.getRow(3).font.color.argb).toBe('ff0000');
243+
244+
expect(worksheet.getCell(4, 1).value).toBe(2);
245+
expect(worksheet.getCell(4, 2).value).toBe(2);
246+
expect(worksheet.getCell(4, 3).value).toBe('');
247+
expect(worksheet.getCell(4, 4).value).toBe('testSeries2');
248+
expect(worksheet.getCell(4, 5).value).toBe('testTitle2');
249+
expect(worksheet.getCell(4, 6).value).toBe('11/12/1972');
250+
expect(worksheet.getCell(4, 7).value).toBe('FALSE');
251+
expect(worksheet.getCell(4, 8).value).toBe('');
252+
expect(worksheet.getCell(4, 9).value).toBe('Hispanic or Latino');
253+
expect(worksheet.getCell(4, 10).value).toBe('Other Race');
254+
expect(worksheet.getCell(4, 11).value).toBe('Female');
255+
expect(worksheet.getCell(4, 12).value).toBe('UNHIT');
256+
expect(worksheet.getCell(4, 13).value).toBe('FUNCTION');
257+
expect(worksheet.getCell(4, 14).value).toBe('FUNCTION');
258+
//success test test cases font color is not red (undefined)
259+
expect(worksheet.getRow(4).font).toBe(undefined);
205260
});
206261

207262
it('test generateXlsx', async () => {

src/services/export.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export class ExportService {
199199
testCasesData.push(testCaseData);
200200
firstRow = firstRowData;
201201
headerRow = headerRowData;
202+
index += 1;
202203
},
203204
);
204205
this.populateFirstRow(worksheet, firstRow);

0 commit comments

Comments
 (0)