Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SJIP-1059 fix request body
Browse files Browse the repository at this point in the history
celinepelletier committed Oct 29, 2024
1 parent 485ebf7 commit ba3bec3
Showing 2 changed files with 16 additions and 28 deletions.
40 changes: 14 additions & 26 deletions src/app.test.ts
Original file line number Diff line number Diff line change
@@ -793,8 +793,18 @@ describe('Express app (without Arranger)', () => {
});

const requestBody = {
genes:
'CYB5R1,TBCA,TOMM5,NRXN2,ENSG00000163462.18,ENSG00000211592,ENSG000002137410,FUT7,AL139424,ENSG00000204882.4',
genes: [
'CYB5R1',
'TBCA',
'TOMM5',
'NRXN2',
'ENSG00000163462.18',
'ENSG00000211592',
'ENSG000002137410',
'FUT7',
'AL139424',
'ENSG00000204882.4',
],
};

it('should return 403 if no Authorization header', () =>
@@ -826,18 +836,7 @@ describe('Express app (without Arranger)', () => {
.send(requestBody)
.expect(200, matchedGenes);
expect((checkGenesExist as jest.Mock).mock.calls.length).toEqual(1);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual([
'CYB5R1',
'TBCA',
'TOMM5',
'NRXN2',
'ENSG00000163462.18',
'ENSG00000211592',
'ENSG000002137410',
'FUT7',
'AL139424',
'ENSG00000204882.4',
]);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual(requestBody.genes);
});

it('should return 500 if Authorization header contains valid token but an error occurs', async () => {
@@ -855,18 +854,7 @@ describe('Express app (without Arranger)', () => {
.send(requestBody)
.expect(500, { error: 'Internal Server Error' });
expect((checkGenesExist as jest.Mock).mock.calls.length).toEqual(1);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual([
'CYB5R1',
'TBCA',
'TOMM5',
'NRXN2',
'ENSG00000163462.18',
'ENSG00000211592',
'ENSG000002137410',
'FUT7',
'AL139424',
'ENSG00000204882.4',
]);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual(requestBody.genes);
});
});
});
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -194,9 +194,9 @@ export default (keycloak: Keycloak, getProject: (projectId: string) => ArrangerP
});

app.postAsync('/transcriptomics/checkGenesExist', keycloak.protect(), async (req, res) => {
const genes: string = req.body.genes;
const genes: string[] = req.body.genes;

const data = await checkGenesExist(genes.split(','));
const data = await checkGenesExist(genes);

res.json(data);
});

0 comments on commit ba3bec3

Please sign in to comment.