From 0c4631af49ff5f4ea9578b809e099df812f9a5e6 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 5 Mar 2026 00:24:34 +0000 Subject: [PATCH 01/18] Implement getAngleType function and add tests Implemented the getAngleType function to classify angles and added tests for various angle types, including acute, obtuse, right, straight, reflex, and invalid angles. --- .../implement/1-get-angle-type.js | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) 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..2453bc4edf 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 @@ -15,7 +15,19 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + if (angle > 0 & angle < 90){ + console.log(angleType = 'acute angle') + }else if (angle == 90){ + console.log(angleType = 'right angle') + }else if (angle > 90 & angle < 180){ + console.log(angleType = 'obtuse angle') + }else if (angle == 180){ + console.log(angleType = 'straight angle') + }else if (angle >180 & angle <360){ + console.log(angleType = 'reflex angle') + }else{ + console.log(angleType = 'invalid angle') + } } // The line below allows us to load the getAngleType function into tests in other files. @@ -35,3 +47,35 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + +// Identify acute Angles +const acute = getAngleType(60); +assertEquals(acute, "acute angle"); + +// Identify obtuse Angles +const obtuse = getAngleType(120); +assertEquals(obtuse, "obtuse angle"); + +// Identify straight Angles +const straight = getAngleType(180); +assertEquals(straight, "straight angle"); + +// Identify reflex Angles +const reflex = getAngleType(250); +assertEquals(reflex, "reflex angle"); + +// Identify invalid Angles +const invalid = getAngleType(0); +assertEquals(invalid, "invalid angle"); + +const invalid = getAngleType(360); +assertEquals(invalid, "invalid angle"); + +const invalid = getAngleType(-100); +assertEquals(invalid, "invalid angle"); + +const invalid = getAngleType(1000); +assertEquals(invalid, "invalid angle"); + + + From 4a2804d9ac394da526fcaf839b9c2352112c1283 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 12 Mar 2026 16:35:30 +0000 Subject: [PATCH 02/18] Implement a function getAngleType and Write tests to cover all cases --- .../implement/1-get-angle-type.js | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) 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 2453bc4edf..68dd202ac7 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 @@ -15,18 +15,18 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - if (angle > 0 & angle < 90){ - console.log(angleType = 'acute angle') - }else if (angle == 90){ - console.log(angleType = 'right angle') - }else if (angle > 90 & angle < 180){ - console.log(angleType = 'obtuse angle') - }else if (angle == 180){ - console.log(angleType = 'straight angle') - }else if (angle >180 & angle <360){ - console.log(angleType = 'reflex angle') - }else{ - console.log(angleType = 'invalid angle') + 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"; } } @@ -76,6 +76,3 @@ assertEquals(invalid, "invalid angle"); const invalid = getAngleType(1000); assertEquals(invalid, "invalid angle"); - - - From 6b4ee505ceadebc8fe05c414c80967b890605a73 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 12 Mar 2026 17:37:08 +0000 Subject: [PATCH 03/18] implement isproperfraction function and rewrite tests to cover all cases --- .../implement/2-is-proper-fraction.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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..0cdc3126d3 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,10 @@ function isProperFraction(numerator, denominator) { // TODO: Implement this function + if (Math.abs(numerator) < Math.abs(denominator)) { + return true; + } else { + return false; } // The line below allows us to load the isProperFraction function into tests in other files. @@ -31,3 +35,15 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); +// Example: 2/1 is not a proper fraction +assertEquals(isProperFraction(2, 1), false); +// Example: 1/2 is a proper fraction +assertEquals(isProperFraction(-1, 2), true); +// Example: -1/2 is a proper fraction +assertEquals(isProperFraction(-1, -2), true); +// Example: 1/2 is a proper fraction +assertEquals(isProperFraction(1, -2), true); +// Example: -2/1 is not a proper fraction +assertEquals(isProperFraction(-2, 1), false); +// Example: 1/2 is not a proper fraction +assertEquals(isProperFraction(-2, -1), false); \ No newline at end of file From 7d502dca76fdbfc2118f7ed763d147757f2ea6ba Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 13 Mar 2026 00:39:55 +0000 Subject: [PATCH 04/18] Implement getCardValue function and added tests for valid and invalid inputs --- .../implement/3-get-card-value.js | 50 +++++++++++++++++++ 1 file changed, 50 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 c7559e787e..049046ef17 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,17 @@ function getCardValue(card) { // TODO: Implement this function + if ( + card.length < 2 || + card.length > 3 || + !["♠", "♥", "♦", "♣"].includes(card.slice(-1)) + ) + throw new Error("invalid suit"); + if (card[0] === "A") return 11; + if (["J", "Q", "K"].includes(card[0])) return 10; + if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(card[0])) + return card[0]; // the parseint() or Number() can be used to convert the string to a number + throw new Error("invalid rank"); } // The line below allows us to load the getCardValue function into tests in other files. @@ -41,6 +52,11 @@ function assertEquals(actualOutput, targetOutput) { // Examples: assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("A♥"), 11); +assertEquals(getCardValue("J♣"), 10); +assertEquals(getCardValue("Q♠"), 10); +assertEquals(getCardValue("2♦"), 2); + // Handling invalid cards try { getCardValue("invalid"); @@ -50,3 +66,37 @@ try { } catch (e) {} // What other invalid card cases can you think of? +try { + getCardValue("S"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +try { + getCardValue("AJKP"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +try { + getCardValue("A❦"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +try { + getCardValue("29"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +try { + getCardValue("♦,♣"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +try { + getCardValue("2345"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +try { + getCardValue(""); + console.error("Error was not thrown for invalid card"); +} catch (e) {} From 82958b579ff536cf4056f599217a7e16a36bab9e Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 13 Mar 2026 00:47:55 +0000 Subject: [PATCH 05/18] validate the first if statement to include the condition there the rank is "10" so the string is 3 characters --- .../1-implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 049046ef17..97676c12b9 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 @@ -25,7 +25,7 @@ function getCardValue(card) { // TODO: Implement this function if ( card.length < 2 || - card.length > 3 || + card.length >= 3 || !["♠", "♥", "♦", "♣"].includes(card.slice(-1)) ) throw new Error("invalid suit"); From c286e4a669a246238feb9c3eac0a71f5c482246b Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 13 Mar 2026 00:50:47 +0000 Subject: [PATCH 06/18] Revert "validate the first if statement to include the condition there the rank is "10" so the string is 3 characters" This reverts commit 82958b579ff536cf4056f599217a7e16a36bab9e. --- .../1-implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 97676c12b9..049046ef17 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 @@ -25,7 +25,7 @@ function getCardValue(card) { // TODO: Implement this function if ( card.length < 2 || - card.length >= 3 || + card.length > 3 || !["♠", "♥", "♦", "♣"].includes(card.slice(-1)) ) throw new Error("invalid suit"); From a70220f87a74ff30ca673d50dfcfd679d0d83da4 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 13 Mar 2026 02:05:59 +0000 Subject: [PATCH 07/18] add tests for all angle types and invalid angles --- .../1-get-angle-type.test.js | 26 +++++++++++++++++++ 1 file changed, 26 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..8b788a7d0b 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,33 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test(`should return "Right angle" when angle is 90`, () => { + expect(getAngleType(90)).toEqual("Right angle"); +}); + // Case 3: Obtuse angles +test(`should return "Obtuse angle" when (90 < angle < 180)`, () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(135)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}); + // Case 4: Straight angle +test(`should return "Straight angle" when angle is 180`, () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); + // Case 5: Reflex angles +test(`should return "Reflex angle" when (180 < angle < 360)`, () => { + expect(getAngleType(181)).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 or angle >= 360)`, () => { + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); From bc11ec7ebf80a4196cc97b45144014ba6d587dfb Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 13 Mar 2026 02:33:50 +0000 Subject: [PATCH 08/18] Write tests in Jest syntax to cover all combinations for isProperFraction function --- .../2-is-proper-fraction.test.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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..a8e22c14a4 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,29 @@ 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 +// Special case: denominator is zero (undefined) test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +// Special case: numerator is zero (proper fraction) +test(`should return true when numerator is zero`, () => { + expect(isProperFraction(0, 1)).toEqual(true); +}); + +// Special case: both numerator and denominator are zeros (undefined) +test(`should return false when both numerator and denominator are zero`, () => { + expect(isProperFraction(0, 0)).toEqual(false); +}); + +// case: the absolute value of the numerater is less than the absolute value of the denominater (proper fraction) +test(`should return true for positive proper fraction`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + +// case: the absolute value of the denominater is less than the absolute value of the numerater (improper fraction) +test(`should return false for positive improper fraction`, () => { + expect(isProperFraction(2, 1)).toEqual(false); +}); + +// no need to test the cases where the denominator or numerator or both are negative as I used their absolute value in the function. From 7eab738c6df788545a63e6609ca05b0d9dfde775 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 13 Mar 2026 03:28:05 +0000 Subject: [PATCH 09/18] Write tests in Jest syntax to cover all possible outcomes. --- .../3-get-card-value.test.js | 76 ++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) 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..6b0551151a 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 @@ -8,13 +8,87 @@ const getCardValue = require("../implement/3-get-card-value"); test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +test(`Should return 11 when given an ace card`, () => { + expect(getCardValue("A♥")).toEqual(11); +}); +test(`Should return 11 when given an ace card`, () => { + expect(getCardValue("A♦")).toEqual(11); +}); +test(`Should return 11 when given an ace card`, () => { + expect(getCardValue("A♣")).toEqual(11); +}); // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) +test(`Should return 2 when given a 2 card`, () => { + expect(getCardValue("2♠")).toEqual(2); +}); +test(`Should return 3 when given a 3 card`, () => { + expect(getCardValue("3♥")).toEqual(3); +}); +test(`Should return 4 when given a 4 card`, () => { + expect(getCardValue("4♦")).toEqual(4); +}); +test(`Should return 5 when given a 5 card`, () => { + expect(getCardValue("5♣")).toEqual(5); +}); +test(`Should return 6 when given a 6 card`, () => { + expect(getCardValue("6♥")).toEqual(6); +}); +test(`Should return 7 when given a 7 card`, () => { + expect(getCardValue("7♠")).toEqual(7); +}); +test(`Should return 8 when given a 8 card`, () => { + expect(getCardValue("8♦")).toEqual(8); +}); +test(`Should return 9 when given a 9 card`, () => { + expect(getCardValue("9♠")).toEqual(9); +}); +test(`Should return 10 when given a 10 card`, () => { + expect(getCardValue("10♣")).toEqual(10); +}); + // Face Cards (J, Q, K) +test(`Should return 10 when given a J card`, () => { + expect(getCardValue("J♠")).toEqual(10); +}); +test(`Should return 10 when given a Q card`, () => { + expect(getCardValue("Q♦")).toEqual(10); +}); +test(`Should return 10 when given a K card`, () => { + expect(getCardValue("K♥")).toEqual(10); +}); // Invalid Cards +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("1♠")).toThrow(); +}); +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("2❦")).toThrow(); +}); + +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("11♥")).toThrow(); +}); +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("B♦")).toThrow(); +}); +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("Z♣")).toThrow(); +}); +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("♣2")).toThrow(); +}); +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("s")).toThrow(); +}); +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("♣♥♠♦")).toThrow(); +}); + +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("")).toThrow(); +}); // 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 - From 3f7c3f84db7e0ab58abf6ce1937b53ec1d91d531 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 15 Mar 2026 19:06:11 +0000 Subject: [PATCH 10/18] enhancement: Implement getCardValue function to return correct card values --- .../implement/3-get-card-value.js | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 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 049046ef17..98554fb5a4 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,17 +23,15 @@ function getCardValue(card) { // TODO: Implement this function - if ( - card.length < 2 || - card.length > 3 || - !["♠", "♥", "♦", "♣"].includes(card.slice(-1)) - ) - throw new Error("invalid suit"); - if (card[0] === "A") return 11; - if (["J", "Q", "K"].includes(card[0])) return 10; - if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(card[0])) - return card[0]; // the parseint() or Number() can be used to convert the string to a number - throw new Error("invalid rank"); + const cardRank = card.slice(0, -1); + const cardSuit = card.slice(-1); + if (card.length < 2 || !["♠", "♥", "♦", "♣"].includes(cardSuit)) + throw new Error("invalid card suit"); + if (cardRank === "A") return 11; + if (["J", "Q", "K"].includes(cardRank)) return 10; + if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(cardRank)) + return cardRank; // the parseint() or Number() can be used to convert the string to a number + throw new Error("invalid card rank"); } // The line below allows us to load the getCardValue function into tests in other files. From 67693411c3177f8e27d89bf37c68e5a82845f5ed Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 15 Mar 2026 19:17:56 +0000 Subject: [PATCH 11/18] fixed syntax error --- .../implement/2-is-proper-fraction.js | 3 ++- 1 file changed, 2 insertions(+), 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 0cdc3126d3..5d5b289d99 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 @@ -16,6 +16,7 @@ function isProperFraction(numerator, denominator) { return true; } else { return false; + } } // The line below allows us to load the isProperFraction function into tests in other files. @@ -46,4 +47,4 @@ assertEquals(isProperFraction(1, -2), true); // Example: -2/1 is not a proper fraction assertEquals(isProperFraction(-2, 1), false); // Example: 1/2 is not a proper fraction -assertEquals(isProperFraction(-2, -1), false); \ No newline at end of file +assertEquals(isProperFraction(-2, -1), false); From f23151697dad3889483edb47e941414cd2b42821 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 03:39:31 +0000 Subject: [PATCH 12/18] combined similar items into one category --- .../3-get-card-value.test.js | 42 +------------------ 1 file changed, 2 insertions(+), 40 deletions(-) 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 6b0551151a..ec36689a64 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 @@ -20,72 +20,34 @@ test(`Should return 11 when given an ace card`, () => { // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) -test(`Should return 2 when given a 2 card`, () => { +test("should return the value of number cards (2-10)", () => { expect(getCardValue("2♠")).toEqual(2); -}); -test(`Should return 3 when given a 3 card`, () => { expect(getCardValue("3♥")).toEqual(3); -}); -test(`Should return 4 when given a 4 card`, () => { expect(getCardValue("4♦")).toEqual(4); -}); -test(`Should return 5 when given a 5 card`, () => { expect(getCardValue("5♣")).toEqual(5); -}); -test(`Should return 6 when given a 6 card`, () => { expect(getCardValue("6♥")).toEqual(6); -}); -test(`Should return 7 when given a 7 card`, () => { expect(getCardValue("7♠")).toEqual(7); -}); -test(`Should return 8 when given a 8 card`, () => { expect(getCardValue("8♦")).toEqual(8); -}); -test(`Should return 9 when given a 9 card`, () => { expect(getCardValue("9♠")).toEqual(9); -}); -test(`Should return 10 when given a 10 card`, () => { expect(getCardValue("10♣")).toEqual(10); }); // Face Cards (J, Q, K) -test(`Should return 10 when given a J card`, () => { +test(`Should return the value of face cards (J, Q, K)`, () => { expect(getCardValue("J♠")).toEqual(10); -}); -test(`Should return 10 when given a Q card`, () => { expect(getCardValue("Q♦")).toEqual(10); -}); -test(`Should return 10 when given a K card`, () => { expect(getCardValue("K♥")).toEqual(10); }); // Invalid Cards test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("1♠")).toThrow(); -}); -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("2❦")).toThrow(); -}); - -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("11♥")).toThrow(); -}); -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("B♦")).toThrow(); -}); -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("Z♣")).toThrow(); -}); -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("♣2")).toThrow(); -}); -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("s")).toThrow(); -}); -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("♣♥♠♦")).toThrow(); -}); - -test(`Should throw an error when given an invalid card`, () => { expect(() => getCardValue("")).toThrow(); }); From 608f1dbbcbfdd31c22f4f9d999a0499129a207c3 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 03:48:34 +0000 Subject: [PATCH 13/18] combined tha ace cases in one category --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 6 ------ 1 file changed, 6 deletions(-) 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 ec36689a64..f73e70e55d 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 @@ -7,14 +7,8 @@ const getCardValue = require("../implement/3-get-card-value"); // Case 1: Ace (A) test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); -}); -test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♥")).toEqual(11); -}); -test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♦")).toEqual(11); -}); -test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♣")).toEqual(11); }); From 9a3c314a8f472998c54e96d1c044aac2c8f0d378 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 04:44:30 +0000 Subject: [PATCH 14/18] added tests for negative numerator/denominator cases --- .../2-is-proper-fraction.test.js | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 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 a8e22c14a4..b6148b4ad7 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 @@ -19,14 +19,42 @@ test(`should return false when both numerator and denominator are zero`, () => { expect(isProperFraction(0, 0)).toEqual(false); }); -// case: the absolute value of the numerater is less than the absolute value of the denominater (proper fraction) +// case: both values are positive and the value of the numerater is less than the value of the denominater (proper fraction) test(`should return true for positive proper fraction`, () => { expect(isProperFraction(1, 2)).toEqual(true); }); -// case: the absolute value of the denominater is less than the absolute value of the numerater (improper fraction) +// case: both values are positive and the value of the denominater is less than the value of the numerater (improper fraction) test(`should return false for positive improper fraction`, () => { expect(isProperFraction(2, 1)).toEqual(false); }); -// no need to test the cases where the denominator or numerator or both are negative as I used their absolute value in the function. +// case: the value of the numerater is negative and its absolute value is less than the value of the denominater (roper fraction) +test(`should return false for proper fraction`, () => { + expect(isProperFraction(-1, 2)).toEqual(true); +}); + +// case: the value of the numerater is negative and its absolute value is greater than the value of the denominater (improper fraction) +test(`should return false for improper fraction`, () => { + expect(isProperFraction(-2, 1)).toEqual(false); +}); + +// case: the value of the denominator is negative and its absolute value is greater than the value of the numerator (proper fraction) +test(`should return true for proper fraction`, () => { + expect(isProperFraction(1, -2)).toEqual(true); +}); + +// case: the value of the denominator is negative and its absolute value is less than the value of the numerator (improper fraction) +test(`should return false for improper fraction`, () => { + expect(isProperFraction(2, -1)).toEqual(false); +}); + +// case: both values of the numerator and denominator are negative and the absolute value of the numerator is less than the absolute value of the denominator (proper fraction) +test(`should return true for proper fraction`, () => { + expect(isProperFraction(-1, -2)).toEqual(true); +}); + +// case: both values of the numerator and denominator are negative and the absolute value of the numerator is greater than the absolute value of the denominator (improper fraction) +test(`should return false for improper fraction`, () => { + expect(isProperFraction(-2, -1)).toEqual(false); +}); From c09907469ece64c5fc5faf75dd73fc1eaf5dd2ff Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 04:50:14 +0000 Subject: [PATCH 15/18] added tests for negative numerator/denominator cases --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 4 ++-- 1 file changed, 2 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 b6148b4ad7..51a5d0ecf3 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 @@ -20,12 +20,12 @@ test(`should return false when both numerator and denominator are zero`, () => { }); // case: both values are positive and the value of the numerater is less than the value of the denominater (proper fraction) -test(`should return true for positive proper fraction`, () => { +test(`should return true for proper fraction`, () => { expect(isProperFraction(1, 2)).toEqual(true); }); // case: both values are positive and the value of the denominater is less than the value of the numerater (improper fraction) -test(`should return false for positive improper fraction`, () => { +test(`should return false for improper fraction`, () => { expect(isProperFraction(2, 1)).toEqual(false); }); From fa537b2d2c946fddb099daf08e29ed19829d3857 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 04:53:21 +0000 Subject: [PATCH 16/18] added tests for negative numerator/denominator cases --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) 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 51a5d0ecf3..ba8de3e9d1 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 @@ -29,6 +29,7 @@ test(`should return false for improper fraction`, () => { expect(isProperFraction(2, 1)).toEqual(false); }); +// testing negative cases // case: the value of the numerater is negative and its absolute value is less than the value of the denominater (roper fraction) test(`should return false for proper fraction`, () => { expect(isProperFraction(-1, 2)).toEqual(true); From 36e8c148579fa480fed0b5fb5773224e22a687fd Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 15:01:09 +0000 Subject: [PATCH 17/18] converted the cardRnk string to a number and added a check for the ace card, which can have a value of either 1 or 11 depending on the context of the hand. This allows the function to correctly calculate the value of the hand in blackjack, where the ace can be counted as either 1 or 11 to maximize the player's chances of winning. --- .../1-implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 98554fb5a4..5f3e11e770 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 @@ -30,7 +30,7 @@ function getCardValue(card) { if (cardRank === "A") return 11; if (["J", "Q", "K"].includes(cardRank)) return 10; if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(cardRank)) - return cardRank; // the parseint() or Number() can be used to convert the string to a number + return Number(cardRank); // the parseint() or Number() can be used to convert the string to a number throw new Error("invalid card rank"); } From af851f3370135f5721b5ceb2cb026287811d9404 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 16 Mar 2026 15:35:48 +0000 Subject: [PATCH 18/18] combine the tests with the same description into the same group --- .../2-is-proper-fraction.test.js | 53 +++++-------------- 1 file changed, 14 insertions(+), 39 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 ba8de3e9d1..f016943068 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 @@ -7,55 +7,30 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); // Special case: denominator is zero (undefined) test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); -}); - -// Special case: numerator is zero (proper fraction) -test(`should return true when numerator is zero`, () => { - expect(isProperFraction(0, 1)).toEqual(true); -}); - -// Special case: both numerator and denominator are zeros (undefined) -test(`should return false when both numerator and denominator are zero`, () => { + // Special case: both numerator and denominator are zeros (undefined) expect(isProperFraction(0, 0)).toEqual(false); }); -// case: both values are positive and the value of the numerater is less than the value of the denominater (proper fraction) +// Special case: numerator is zero (proper fraction) test(`should return true for proper fraction`, () => { + expect(isProperFraction(0, 1)).toEqual(true); + // case: both values are positive and the value of the numerater is less than the value of the denominater (proper fraction) expect(isProperFraction(1, 2)).toEqual(true); -}); - -// case: both values are positive and the value of the denominater is less than the value of the numerater (improper fraction) -test(`should return false for improper fraction`, () => { - expect(isProperFraction(2, 1)).toEqual(false); -}); - -// testing negative cases -// case: the value of the numerater is negative and its absolute value is less than the value of the denominater (roper fraction) -test(`should return false for proper fraction`, () => { + // case: the value of the numerater is negative and its absolute value is less than the value of the denominater (roper fraction) expect(isProperFraction(-1, 2)).toEqual(true); -}); - -// case: the value of the numerater is negative and its absolute value is greater than the value of the denominater (improper fraction) -test(`should return false for improper fraction`, () => { - expect(isProperFraction(-2, 1)).toEqual(false); -}); - -// case: the value of the denominator is negative and its absolute value is greater than the value of the numerator (proper fraction) -test(`should return true for proper fraction`, () => { + // case: the value of the denominator is negative and its absolute value is greater than the value of the numerator (proper fraction) expect(isProperFraction(1, -2)).toEqual(true); -}); - -// case: the value of the denominator is negative and its absolute value is less than the value of the numerator (improper fraction) -test(`should return false for improper fraction`, () => { - expect(isProperFraction(2, -1)).toEqual(false); -}); - -// case: both values of the numerator and denominator are negative and the absolute value of the numerator is less than the absolute value of the denominator (proper fraction) -test(`should return true for proper fraction`, () => { + // case: both values of the numerator and denominator are negative and the absolute value of the numerator is less than the absolute value of the denominator (proper fraction) expect(isProperFraction(-1, -2)).toEqual(true); }); -// case: both values of the numerator and denominator are negative and the absolute value of the numerator is greater than the absolute value of the denominator (improper fraction) +// case: both values are positive and the value of the denominater is less than the value of the numerater (improper fraction) test(`should return false for improper fraction`, () => { + expect(isProperFraction(2, 1)).toEqual(false); + // case: the value of the numerater is negative and its absolute value is greater than the value of the denominater (improper fraction) + expect(isProperFraction(-2, 1)).toEqual(false); + // case: both values of the numerator and denominator are negative and the absolute value of the numerator is greater than the absolute value of the denominator (improper fraction) expect(isProperFraction(-2, -1)).toEqual(false); + // case: the value of the denominator is negative and its absolute value is less than the value of the numerator (improper fraction) + expect(isProperFraction(2, -1)).toEqual(false); });