Skip to content

Commit

Permalink
Merge pull request #115 from snyk/chore/test-fix
Browse files Browse the repository at this point in the history
chore: adjusted tests according to latest engine improvements
  • Loading branch information
Arvi3d authored Nov 8, 2021
2 parents 0c59c18 + 8f44982 commit d0cdb11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
21 changes: 8 additions & 13 deletions tests/analysis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
Expand Down Expand Up @@ -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',
},
]),
);

Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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> = T extends PromiseLike<infer U> ? Awaited<U> : T;
Expand All @@ -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,
Expand Down
12 changes: 4 additions & 8 deletions tests/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('Requests to public API', () => {
'.js',
'.jsx',
'.php',
'.phtml',
'.py',
'.rb',
'.rhtml',
Expand Down Expand Up @@ -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([
Expand All @@ -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',
},
]),
);
}
Expand All @@ -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 {
Expand Down

0 comments on commit d0cdb11

Please sign in to comment.