Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 committed Nov 22, 2024
1 parent ebdb8b7 commit 012d706
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion test/reportUpload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Tests for uploading a report and all of its components', () => {

test('Genes entries were created correctly from variant and gene rows', async () => {
const genes = await db.models.genes.findAll({where: {reportId}});
expect(genes).toHaveProperty('length', 5);
expect(genes).toHaveProperty('length', 6);

// gene flags should be added from genes section if given
expect(genes).toEqual(expect.arrayContaining([expect.objectContaining({
Expand Down Expand Up @@ -123,6 +123,26 @@ describe('Tests for uploading a report and all of its components', () => {
expect(boundUser.user_id).toBe(report.createdBy_id);
});

test('Only multivariant kbstatements are linked to multiple nested kbvariants', async () => {
// Get Kbstatements and check that only multivariant inputs have multiple kbvariants
const res = await request
.get(`/api/reports/${reportIdent}/kb-matches/kb-matched-statements`)
.auth(username, password)
.type('json')
.expect(HTTP_STATUS.OK);

const singleVariantStatements = res.body.filter((item) => {return item.context !== 'test multivariant statement';}); // Replace 'value1' with the specific value for x1
const multiVariantStatements = res.body.filter((item) => {return item.context === 'test multivariant statement';});

expect(singleVariantStatements.every((item) => {return Array.isArray(item.kbMatches) && item.kbMatches.length === 1;})).toBe(true);
expect(multiVariantStatements.every((item) => {return Array.isArray(item.kbMatches) && item.kbMatches.length === 2;})).toBe(true);
expect(multiVariantStatements).toHaveProperty('length', 1);
});

test('Kbvariants are linked to their nested kbstatements', async () => {

});

afterAll(async () => {
// Delete newly created report and all of it's components
// by force deleting the report
Expand Down
2 changes: 1 addition & 1 deletion test/testData/mockReportData.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"disease": "colorectal cancer [DOID:9256]",
"kbStatementId": "#999:999",
"matchedCancer": true,
"reference": "pmid:TEST2",
"reference": "pmid:TEST1",
"relevance": "resistance",
"iprEvidenceLevel": "IPR-D",
"externalSource": "IPRKB",
Expand Down

0 comments on commit 012d706

Please sign in to comment.