Skip to content

Commit

Permalink
#6 Testing calculateThreatScope
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewNobes committed Jun 14, 2022
1 parent 05a2520 commit b715c3d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const calculateLikelihood = (values) => {
* @param {boolean} Q2 The users answer for Q2.
* @returns {string} The threat scope
*/
const calculateThreatScope = (Q1, Q2) => {
export const calculateThreatScope = (Q1, Q2) => {
if (Q1 === true && Q2 === true) {
return "High";
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { calculateThreatScope } from "./calculateLikelihood";

describe("testing the calculateThreatScope function", () => {
it("should return High if Q1 & Q2 are both true", () => {
const expectValue = "High";
const Q1Value = true;
const Q2Value = true;
expect(calculateThreatScope(Q1Value, Q2Value)).toBe(expectValue);
});

it("should return Low if Q1 & Q2 are both true", () => {
const expectValue = "Low";
const Q1Value = false;
const Q2Value = false;
expect(calculateThreatScope(Q1Value, Q2Value)).toBe(expectValue);
});

it("should return Medium if Q1 is true & Q2 is false", () => {
const expectValue = "Medium";
const Q1Value = true;
const Q2Value = false;
expect(calculateThreatScope(Q1Value, Q2Value)).toBe(expectValue);
});

it("should return Medium if Q1 is false & Q2 is true", () => {
const expectValue = "Medium";
const Q1Value = false;
const Q2Value = true;
expect(calculateThreatScope(Q1Value, Q2Value)).toBe(expectValue);
});
});

0 comments on commit b715c3d

Please sign in to comment.