Skip to content

Commit 39e29cb

Browse files
committed
chore: increase coverage on template_nine api
1 parent 557f466 commit 39e29cb

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

app/tests/backend/lib/excel_import/template_nine.test.ts

+48
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,52 @@ describe('The Community Progress Report import', () => {
342342

343343
expect(response.status).toBe(200);
344344
});
345+
346+
it('should reject if a guest tries to process applicant rfi endpoint', async () => {
347+
mocked(getAuthRole).mockImplementation(() => {
348+
return {
349+
pgRole: 'ccbc_guest',
350+
landingRoute: '/',
351+
};
352+
});
353+
354+
const response = await request(app).post(
355+
'/api/template-nine/rfi/applicant/1/CCBC-00001-1'
356+
);
357+
358+
expect(response.status).toBe(404);
359+
});
360+
361+
it('should return 400 if an applicant tries to process bad file', async () => {
362+
mocked(getAuthRole).mockImplementation(() => {
363+
return {
364+
pgRole: 'ccbc_auth_user',
365+
landingRoute: '/',
366+
};
367+
});
368+
369+
const response = await request(app)
370+
.post('/api/template-nine/rfi/applicant/1/CCBC-00001-1')
371+
.set('Content-Type', 'application/json')
372+
.set('Connection', 'keep-alive')
373+
.field('data', JSON.stringify({ name: 'form' }))
374+
.attach('template9', null);
375+
376+
expect(response.status).toBe(400);
377+
});
378+
379+
it('should return 400 if an applicant tries to hit endpoint with bad parameters', async () => {
380+
mocked(getAuthRole).mockImplementation(() => {
381+
return {
382+
pgRole: 'ccbc_auth_user',
383+
landingRoute: '/',
384+
};
385+
});
386+
387+
const response = await request(app).post(
388+
'/api/template-nine/rfi/applicant/null/rfi'
389+
);
390+
391+
expect(response.status).toBe(400);
392+
});
345393
});

0 commit comments

Comments
 (0)