From 8f44982bcf9843a444be36b78b3dbca972507e36 Mon Sep 17 00:00:00 2001 From: Arvyd Paeglit Date: Mon, 8 Nov 2021 18:11:47 +0000 Subject: [PATCH] chore: adjusted tests according to latest engine improvements --- tests/analysis.spec.ts | 21 ++++++++------------- tests/api.spec.ts | 12 ++++-------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/tests/analysis.spec.ts b/tests/analysis.spec.ts index bcb0d2f7..02b34e9f 100644 --- a/tests/analysis.spec.ts +++ b/tests/analysis.spec.ts @@ -68,8 +68,8 @@ describe('Functional test of analysis', () => { expect(bundle.analysisResults.type === 'sarif').toBeTruthy(); if (bundle.analysisResults.type !== 'sarif') return; - expect(bundle.analysisResults.sarif.runs[0].tool.driver.rules?.length).toEqual(7); - expect(bundle.analysisResults.sarif.runs[0].results?.length).toEqual(12); + expect(bundle.analysisResults.sarif.runs[0].tool.driver.rules?.length).toEqual(10); + expect(bundle.analysisResults.sarif.runs[0].results?.length).toEqual(17); const sampleRes = bundle.analysisResults.sarif.runs[0].results!.find( res => res.locations?.[0].physicalLocation?.artifactLocation?.uri === `GitHubAccessTokenScrambler12.java`, ); @@ -98,15 +98,10 @@ describe('Functional test of analysis', () => { lang: 'C++ (beta)', }, { - files: 5, + files: 6, isSupported: true, lang: 'JavaScript', }, - { - files: 1, - isSupported: true, - lang: 'JSX', - }, ]), ); @@ -168,7 +163,7 @@ describe('Functional test of analysis', () => { if (bundle.analysisResults.type !== 'legacy') return; expect(Object.keys(bundle.analysisResults.files)).toHaveLength(5); - expect(Object.keys(bundle.analysisResults.suggestions)).toHaveLength(8); + expect(Object.keys(bundle.analysisResults.suggestions)).toHaveLength(11); }); it('analyze folder - with sarif returned', async () => { @@ -226,8 +221,8 @@ describe('Functional test of analysis', () => { expect(fileAnalysis.analysisResults.type === 'sarif').toBeTruthy(); if (fileAnalysis.analysisResults.type !== 'sarif') return; - expect(fileAnalysis.analysisResults.sarif.runs[0].tool.driver.rules).toHaveLength(7); - expect(fileAnalysis.analysisResults.sarif.runs[0].results).toHaveLength(12); + expect(fileAnalysis.analysisResults.sarif.runs[0].tool.driver.rules).toHaveLength(10); + expect(fileAnalysis.analysisResults.sarif.runs[0].results).toHaveLength(17); const extender = await bundleExtender(); type Awaited = T extends PromiseLike ? Awaited : T; @@ -252,8 +247,8 @@ describe('Functional test of analysis', () => { const sarifResults = extendedBundle.analysisResults.sarif; - expect(sarifResults.runs[0].tool.driver.rules).toHaveLength(5); - expect(sarifResults.runs[0].results).toHaveLength(10); + expect(sarifResults.runs[0].tool.driver.rules).toHaveLength(7); + expect(sarifResults.runs[0].results).toHaveLength(15); const getRes = (path: string) => sarifResults.runs[0].results!.find( res => res.locations?.[0].physicalLocation?.artifactLocation?.uri === path, diff --git a/tests/api.spec.ts b/tests/api.spec.ts index 323121f2..be429141 100644 --- a/tests/api.spec.ts +++ b/tests/api.spec.ts @@ -53,6 +53,7 @@ describe('Requests to public API', () => { '.js', '.jsx', '.php', + '.phtml', '.py', '.rb', '.rhtml', @@ -275,7 +276,7 @@ describe('Requests to public API', () => { expect(response.value.status !== AnalysisStatus.failed).toBeTruthy(); if (response.value.status === AnalysisStatus.complete && response.value.type === 'sarif' ) { - expect(response.value.sarif.runs[0].results).toHaveLength(12); + expect(response.value.sarif.runs[0].results).toHaveLength(17); expect(new Set(response.value.coverage)).toEqual( new Set([ @@ -290,15 +291,10 @@ describe('Requests to public API', () => { lang: 'C++ (beta)', }, { - files: 5, + files: 6, isSupported: true, lang: 'JavaScript', }, - { - files: 1, - isSupported: true, - lang: 'JSX', - }, ]), ); } @@ -322,7 +318,7 @@ describe('Requests to public API', () => { expect(response.value.type === 'sarif').toBeTruthy(); if (response.value.type !== 'sarif') return; - expect(response.value.sarif.runs[0].results).toHaveLength(8); + expect(response.value.sarif.runs[0].results).toHaveLength(12); // Get analysis results with severity 3 do {