Skip to content

Commit

Permalink
feat: Add tests for calc total of productvulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Aug 31, 2023
1 parent c5ef32d commit 65e9bb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,37 +336,43 @@ describe("Productvulnerabilities test", () => {
const line4 = result[4];
const line5 = result[5];
const PRODUCT_COLUMN = 0;
const TOTAL_COLUMN = 1;
const CVE_2016_0173_COLUMN = 2;
const CVE_2018_0172_COLUMN = 3;
const CVE_2019_0171_COLUMN = 4;
const CVE_2020_0174_COLUMN = 5;
expect(result.length).toBe(6);
// Product A
expect(line1[PRODUCT_COLUMN]).toBe("Product A");
expect(line1[TOTAL_COLUMN]).toBe("K");
expect(line1[CVE_2016_0173_COLUMN]).toBe("");
expect(line1[CVE_2018_0172_COLUMN]).toBe("");
expect(line1[CVE_2019_0171_COLUMN]).toBe(ProductStatusSymbol.KNOWN_AFFECTED);
expect(line1[CVE_2020_0174_COLUMN]).toBe("");
// Product B
expect(line2[PRODUCT_COLUMN]).toBe("Product B");
expect(line2[TOTAL_COLUMN]).toBe("K");
expect(line2[CVE_2016_0173_COLUMN]).toBe("");
expect(line2[CVE_2018_0172_COLUMN]).toBe("");
expect(line2[CVE_2019_0171_COLUMN]).toBe(ProductStatusSymbol.KNOWN_AFFECTED);
expect(line2[CVE_2020_0174_COLUMN]).toBe("");
// Product C
expect(line3[PRODUCT_COLUMN]).toBe("Product C");
expect(line3[TOTAL_COLUMN]).toBe("K");
expect(line3[CVE_2016_0173_COLUMN]).toBe("");
expect(line3[CVE_2018_0172_COLUMN]).toBe(ProductStatusSymbol.KNOWN_AFFECTED);
expect(line3[CVE_2019_0171_COLUMN]).toBe("");
expect(line3[CVE_2020_0174_COLUMN]).toBe("");
// Product D
expect(line4[PRODUCT_COLUMN]).toBe("Product D");
expect(line4[TOTAL_COLUMN]).toBe("F");
expect(line4[CVE_2016_0173_COLUMN]).toBe("");
expect(line4[CVE_2018_0172_COLUMN]).toBe("");
expect(line4[CVE_2019_0171_COLUMN]).toBe("");
expect(line4[CVE_2020_0174_COLUMN]).toBe(ProductStatusSymbol.FIXED);
//Product E
expect(line5[PRODUCT_COLUMN]).toBe("Product E");
expect(line5[TOTAL_COLUMN]).toBe("N");
expect(line5[CVE_2016_0173_COLUMN]).toBe(
ProductStatusSymbol.NOT_AFFECTED + ProductStatusSymbol.RECOMMENDED
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const generateLineWith = (product: Product, vulnerabilities: Vulnerability[]) =>
case line.includes("F"):
result = "F";
break;
case line.includes("NR"):
case line.includes("N"):
result = "N";
break;
Expand Down

0 comments on commit 65e9bb6

Please sign in to comment.