From c4261fd6cc2e157437074c1c5ff5953269072c25 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 4 Jul 2026 21:48:31 +0100 Subject: [PATCH 01/12] if condition created inside getAngleType function to evaluate the type of angle --- .../implement/1-get-angle-type.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e2..d5b3343dfe 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -16,6 +16,19 @@ function getAngleType(angle) { // TODO: Implement this function + if (angle > 0 && angle < 90) { + return "Acute angle"; + } else if (angle === 90) { + return "Right angle"; + } else if (angle > 90 && angle < 180) { + return "Obtuse angle"; + } else if (angle === 180) { + return "Straight angle"; + } else if (angle > 180 && angle < 360) { + return "Reflex angle"; + } else { + return "Invalid angle"; + } } // The line below allows us to load the getAngleType function into tests in other files. From 3331c94ff9f7b925e4464d1330dcb74114aca8be Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 7 Jul 2026 11:35:26 +0100 Subject: [PATCH 02/12] Test cases for Right and Obtuse angles created. --- .../1-get-angle-type.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index d777f348d3..a34b99e4fc 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -14,7 +14,20 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test(`should return "Right angle" when (angle === 90)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(89)).toEqual("Right angle"); + expect(getAngleType(90)).toEqual("Right angle"); + expect(getAngleType(91)).toEqual("Right angle"); +}); + // Case 3: Obtuse angles +test(`should return "Obtuse angle" when (angle > 90 && angle < 180)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(145)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}); // Case 4: Straight angle // Case 5: Reflex angles // Case 6: Invalid angles From d16b7fbf4000cacb5db4349033dc0f2486d495cf Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 7 Jul 2026 11:52:16 +0100 Subject: [PATCH 03/12] Test cases for Straight, Reflex and Invalid angles created and tested. --- .../1-get-angle-type.test.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index a34b99e4fc..98eaf63728 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -15,19 +15,36 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { // Case 2: Right angle test(`should return "Right angle" when (angle === 90)`, () => { - // Test various acute angles, including boundary cases - expect(getAngleType(89)).toEqual("Right angle"); + // Test Right angles. expect(getAngleType(90)).toEqual("Right angle"); - expect(getAngleType(91)).toEqual("Right angle"); }); // Case 3: Obtuse angles test(`should return "Obtuse angle" when (angle > 90 && angle < 180)`, () => { - // Test various acute angles, including boundary cases + // Test various Obtuse angles, including boundary cases expect(getAngleType(91)).toEqual("Obtuse angle"); expect(getAngleType(145)).toEqual("Obtuse angle"); expect(getAngleType(179)).toEqual("Obtuse angle"); }); + // Case 4: Straight angle +test(`should return "Straight angle" when (angle === 180)`, () => { + // Test Obtuse angles. + expect(getAngleType(180)).toEqual("Straight angle"); +}); + // Case 5: Reflex angles +test(`should return "Reflex angle" when (angle > 180 && angle < 360)`, () => { + // Test various Reflex angles, including boundary cases + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(240)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); + // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle < 0 && angle > 360)`, () => { + // Test various Invalid angles that are less that 0 or above 360 degrees. + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); + From c3617ce7a981e97b8c9dfc080210d7455694e6b4 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 7 Jul 2026 12:10:49 +0100 Subject: [PATCH 04/12] More test cases added for invalid angles including negative numbers. --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 98eaf63728..ca052f15aa 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -23,7 +23,7 @@ test(`should return "Right angle" when (angle === 90)`, () => { test(`should return "Obtuse angle" when (angle > 90 && angle < 180)`, () => { // Test various Obtuse angles, including boundary cases expect(getAngleType(91)).toEqual("Obtuse angle"); - expect(getAngleType(145)).toEqual("Obtuse angle"); + expect(getAngleType(135)).toEqual("Obtuse angle"); expect(getAngleType(179)).toEqual("Obtuse angle"); }); @@ -37,14 +37,15 @@ test(`should return "Straight angle" when (angle === 180)`, () => { test(`should return "Reflex angle" when (angle > 180 && angle < 360)`, () => { // Test various Reflex angles, including boundary cases expect(getAngleType(181)).toEqual("Reflex angle"); - expect(getAngleType(240)).toEqual("Reflex angle"); + expect(getAngleType(270)).toEqual("Reflex angle"); expect(getAngleType(359)).toEqual("Reflex angle"); }); // Case 6: Invalid angles test(`should return "Invalid angle" when (angle < 0 && angle > 360)`, () => { - // Test various Invalid angles that are less that 0 or above 360 degrees. + // Test various Invalid angles that are less that are negative number, 0 and numbers that are above 360 degrees. + expect(getAngleType(-9)).toEqual("Invalid angle"); expect(getAngleType(0)).toEqual("Invalid angle"); - expect(getAngleType(361)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); + expect(getAngleType(450)).toEqual("Invalid angle"); }); - From 29fc3b32fe0f39ed3ef273b18cc6ccf01d4bcef6 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 7 Jul 2026 13:39:46 +0100 Subject: [PATCH 05/12] A return expression added into isProperFraction function --- .../implement/2-is-proper-fraction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 970cb9b641..0985d513a8 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -12,6 +12,7 @@ function isProperFraction(numerator, denominator) { // TODO: Implement this function + return numerator > 0 && numerator < denominator; } // The line below allows us to load the isProperFraction function into tests in other files. From be2fbc266e200cfd7854e9362b7fadb8af3292ed Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 11 Jul 2026 22:27:38 +0100 Subject: [PATCH 06/12] All possible special and non special case of test written. --- .../2-is-proper-fraction.test.js | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 7f087b2ba1..fa054a308e 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -4,7 +4,74 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. -// Special case: numerator is zero -test(`should return false when denominator is zero`, () => { +// Special case 1: numerator is zero +test(`should return false when numerator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +// Special case 2: denominator zero +test(`should return false when denominator is zero`, () => { + expect(isProperFraction(0, 1)).toEqual(false); +}); + +// Special case 3: both zero +test(`should return false when both are zero`, () => { + expect(isProperFraction(0, 0)).toEqual(false); +}); + +// Special case 4: numerator is a negative number +test(`should return false when numerator is negative`, () => { + expect(isProperFraction(-3, 4)).toEqual(false); +}); + +// Special case 5: denominator is a negative number +test(`should return false when denominator is negative`, () => { + expect(isProperFraction(3, -4)).toEqual(false); +}); + +// Special case 6: numerator -3 and denominator -4 +test(`should return false when numerator -3 and denominator -4`, () => { + expect(isProperFraction(-3, -4)).toEqual(false); +}); + +// Special case 7: negative equal values +test(`should return false when both negative equal values`, () => { + expect(isProperFraction(-6, -6)).toEqual(false); +}); + +// Special case 8: equal values +test(`should return false when both are equal`, () => { + expect(isProperFraction(5, 5)).toEqual(false); +}); + +// Special case 9: numerator is a negative number +test(`should return false when numerator is negative`, () => { + expect(isProperFraction(-3, 4)).toEqual(false); +}); + +// Non special cases + +// Case ase 10: numerator 1 denominator 2 +test(`should return false when numerator 1 denominator 2`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + +// Case ase 11: numerator 3 denominator 4 +test(`should return false when numerator 3 denominator 4`, () => { + expect(isProperFraction(3, 4)).toEqual(true); +}); + +// Case ase 12: numerator 5 denominator 8 +test(`should return false when numerator 5 denominator 8`, () => { + expect(isProperFraction(5, 8)).toEqual(true); +}); + +// Case ase 13: numerator 7 denominator 4 +test(`should return false when 7 denominator 4`, () => { + expect(isProperFraction(7, 4)).toEqual(false); +}); + +// Case ase 14: numerator 9 denominator 5 +test(`should return false when numerator 9 denominator 5`, () => { + expect(isProperFraction(9, 5)).toEqual(false); +}); From e05bc8fd1db00369e5d524da1a275411acb12799 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 11 Jul 2026 22:29:35 +0100 Subject: [PATCH 07/12] isProperFraction provided with a return expression to evaluate proper fractions. --- .../implement/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 0985d513a8..7e0e5cff14 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -12,7 +12,7 @@ function isProperFraction(numerator, denominator) { // TODO: Implement this function - return numerator > 0 && numerator < denominator; + return numerator > 0 && numerator < denominator; // expression to compare proper fraction } // The line below allows us to load the isProperFraction function into tests in other files. From 6794148a15488f1530c916dc8a64c01b4ff46169 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 12 Jul 2026 21:18:21 +0100 Subject: [PATCH 08/12] If statements created inside the function to check for valid string of card rank and suits. --- .../implement/3-get-card-value.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index ff5c532e1d..e576d533a0 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -23,6 +23,41 @@ function getCardValue(card) { // TODO: Implement this function + + const validRanks = [ // An array of ranks are created here + "A", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "J", + "Q", + "K", + ]; + const validSuits = ["♠", "♥", "♦", "♣"]; // An array of suits are created here. + + if (typeof card !== "string") { // Here the type of values are checked whether they are string. + throw new Error("Invalid card: " + card); + } + const suit = card.slice(-1); + const rank = card.slice(0, -1); + + if (!validRanks.includes(rank) || !validSuits.includes(suit)) { //Here the values that are stored in rank and suit are checked whether they are valid are inside the validRank and validSuits arrays. + throw new Error("Invalid card: " + card); + } + + if (rank === "A") { // Here the code is testing wether the rank is an Ace. + return 11; + } else if (cards === "J" || rank === "Q" || rank === "K") { // Here the ranks are checked if they are J, Q or K and it returns 10 + return 10; + } else { // Lastly any rank between 2 and 10 get checked and the same number of value returned. + return Number(rank); + } } // The line below allows us to load the getCardValue function into tests in other files. From 7c99da684aaeac047ddc9805d367eb37eaef067e Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 12 Jul 2026 22:21:06 +0100 Subject: [PATCH 09/12] Test cases for all possible valid and invalid cards created and tested. --- .../implement/3-get-card-value.js | 6 ++-- .../3-get-card-value.test.js | 29 ++++++++++++++++++- package.json | 6 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index e576d533a0..4aa1d7e693 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -42,18 +42,18 @@ function getCardValue(card) { const validSuits = ["♠", "♥", "♦", "♣"]; // An array of suits are created here. if (typeof card !== "string") { // Here the type of values are checked whether they are string. - throw new Error("Invalid card: " + card); + return card + " Invalid card"; } const suit = card.slice(-1); const rank = card.slice(0, -1); if (!validRanks.includes(rank) || !validSuits.includes(suit)) { //Here the values that are stored in rank and suit are checked whether they are valid are inside the validRank and validSuits arrays. - throw new Error("Invalid card: " + card); + return card + " Invalid card"; } if (rank === "A") { // Here the code is testing wether the rank is an Ace. return 11; - } else if (cards === "J" || rank === "Q" || rank === "K") { // Here the ranks are checked if they are J, Q or K and it returns 10 + } else if (rank === "J" || rank === "Q" || rank === "K") { // Here the ranks are checked if they are J, Q or K and it returns 10 return 10; } else { // Lastly any rank between 2 and 10 get checked and the same number of value returned. return Number(rank); diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index cf7f9dae2e..7bef44fbd4 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -9,6 +9,34 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +// Case 2: Face Cards (J, Q, K) +test(`Should return 10 when given a face card`, () => { + expect(getCardValue("K♦")).toEqual(10); + expect(getCardValue("Q♥")).toEqual(10); + expect(getCardValue("J♣")).toEqual(10); +}); + +// Case 3: Number Cards (2-10) +test(`Should return the card value when given number card`, () => { + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("3♥")).toEqual(3); + expect(getCardValue("4♦")).toEqual(4); + expect(getCardValue("5♥")).toEqual(5); + expect(getCardValue("6♣")).toEqual(6); + expect(getCardValue("7♠")).toEqual(7); + expect(getCardValue("8♦")).toEqual(8); + expect(getCardValue("9♥")).toEqual(9); + expect(getCardValue("10♣")).toEqual(10); +}); + +// Case 4: Invalid Cards +test(`Should return invalid cards when given a face card`, () => { + expect(getCardValue("1♦")).toEqual("Invalid card"); + expect(getCardValue("10")).toEqual("Invalid card"); + expect(getCardValue("AZ")).toEqual("Invalid card"); + expect(getCardValue("")).toEqual("Invalid card"); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) @@ -17,4 +45,3 @@ test(`Should return 11 when given an ace card`, () => { // To learn how to test whether a function throws an error as expected in Jest, // please refer to the Jest documentation: // https://jestjs.io/docs/expect#tothrowerror - diff --git a/package.json b/package.json index 0657e22dd8..5ebcdf7334 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "keywords": [], "author": "Code Your Future", "license": "ISC", - "dependencies": { - "jest": "^29.7.0" + "devDependencies": { + "jest": "^30.4.2" } -} \ No newline at end of file +} From 196cd5f5c2264e18de0e9eae8db398049027d3a4 Mon Sep 17 00:00:00 2001 From: russom-g Date: Sun, 19 Jul 2026 21:40:26 +0100 Subject: [PATCH 10/12] Delete package.json File deleted as PR wasn't accepting it. --- package.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 package.json diff --git a/package.json b/package.json deleted file mode 100644 index 5ebcdf7334..0000000000 --- a/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "module-structuring-and-testing-data", - "version": "1.0.0", - "description": "Like learning a musical instrument, programming requires daily practice.", - "main": "index.js", - "scripts": { - "test": "jest" - }, - "keywords": [], - "author": "Code Your Future", - "license": "ISC", - "devDependencies": { - "jest": "^30.4.2" - } -} From f4ea51e329ba3fcc7790597fa6679b0eddbe223c Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 20 Jul 2026 14:35:57 +0100 Subject: [PATCH 11/12] Reinstating package json --- package.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000000..0657e22dd8 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "module-structuring-and-testing-data", + "version": "1.0.0", + "description": "Like learning a musical instrument, programming requires daily practice.", + "main": "index.js", + "scripts": { + "test": "jest" + }, + "keywords": [], + "author": "Code Your Future", + "license": "ISC", + "dependencies": { + "jest": "^29.7.0" + } +} \ No newline at end of file From 5fb7cfb408bcfc8826183d025c8db8d829a92a51 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 21 Jul 2026 12:31:23 +0100 Subject: [PATCH 12/12] If statement for checking invalid card implemented --- .../implement/3-get-card-value.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index 4aa1d7e693..de63a96fae 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -23,6 +23,10 @@ function getCardValue(card) { // TODO: Implement this function + if (card <= 1 && card >= 10 || typeof card !== "string") { + // Here the type of values are checked whether they are string. + return card + " Invalid card"; + } const validRanks = [ // An array of ranks are created here "A", @@ -40,10 +44,6 @@ function getCardValue(card) { "K", ]; const validSuits = ["♠", "♥", "♦", "♣"]; // An array of suits are created here. - - if (typeof card !== "string") { // Here the type of values are checked whether they are string. - return card + " Invalid card"; - } const suit = card.slice(-1); const rank = card.slice(0, -1);