diff --git a/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.js b/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.js index b2ba8df..b70df88 100644 --- a/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.js +++ b/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.js @@ -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 { diff --git a/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.test.js b/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.test.js new file mode 100644 index 0000000..c5cbde3 --- /dev/null +++ b/src/features/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.test.js @@ -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); + }); +});