From 5061ffe921e0e613be07eb51e47af85189ea7733 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Thu, 5 Feb 2026 00:46:32 +0000 Subject: [PATCH 01/13] feat: add conditional structure to check angles in the function --- .../implement/1-get-angle-type.js | 15 ++++++++++++++- 1 file changed, 14 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 9e05a871e..c53a75e17 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 < 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"; + } + return "invalid angle"; + } // The line below allows us to load the getAngleType function into tests in other files. @@ -35,3 +47,4 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + From 9d4fb3c5d12c31c4ab38e2fb4109fc23eade4c93 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Sat, 14 Feb 2026 16:26:42 +0000 Subject: [PATCH 02/13] testing a comment line --- Sprint-2/3-mandatory-implement/1-bmi.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1..1825ca005 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -16,4 +16,8 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height -} \ No newline at end of file +} + + + +// update the code below to test your function with different inputs \ No newline at end of file From f9a510ee8f8e80fbc7a64c2b1bdf713abbc05529 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Feb 2026 15:34:12 +0000 Subject: [PATCH 03/13] test: add assert casses to the helper to verify getAngleType logic and boundaries --- .../implement/1-get-angle-type.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 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 c53a75e17..702ed9242 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,7 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - if(angle < 90){ + if(angle > 0 && angle < 90){ return "Acute angle"; } else if (angle === 90){ return "Right angle"; @@ -26,7 +26,7 @@ function getAngleType(angle) { } else if (angle > 180 && angle < 360){ return "Reflex angle"; } - return "invalid angle"; + return "Invalid angle"; } @@ -37,14 +37,31 @@ module.exports = getAngleType; // This helper function is written to make our assertions easier to read. // If the actual output matches the target output, the test will pass function assertEquals(actualOutput, targetOutput) { + console.assert( actualOutput === targetOutput, - `Expected ${actualOutput} to equal ${targetOutput}` + `❌ Error: expected ${actualOutput} to equal ${targetOutput}` ); + + if (actualOutput === targetOutput) { + console.log(`✅ Test passed: ${actualOutput} equals ${targetOutput}`); + } + } // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles -const right = getAngleType(90); +const right = getAngleType(45); assertEquals(right, "Right angle"); +const acute = getAngleType(45); +assertEquals(acute, "Acute angle"); +const obtuse = getAngleType(180); +assertEquals(obtuse, "Obtuse angle"); +const straight = getAngleType(180); +assertEquals(straight, "Straight angle"); +const reflex = getAngleType(240); +assertEquals(reflex, "Reflex angle"); +const invalid = getAngleType(-10); +assertEquals(invalid, "Invalid angle"); +console.log("✓ All test executed!"); From 920734504343ec901cb954b9febe1dad4631e35a Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Feb 2026 16:46:11 +0000 Subject: [PATCH 04/13] test: add cases for proper and improper fractions --- .../implement/1-get-angle-type.js | 4 ++-- .../implement/2-is-proper-fraction.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 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 702ed9242..d3e6e9a43 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 @@ -51,11 +51,11 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles -const right = getAngleType(45); +const right = getAngleType(90); assertEquals(right, "Right angle"); const acute = getAngleType(45); assertEquals(acute, "Acute angle"); -const obtuse = getAngleType(180); +const obtuse = getAngleType(110); assertEquals(obtuse, "Obtuse angle"); const straight = getAngleType(180); assertEquals(straight, "Straight angle"); 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 970cb9b64..056b50560 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 @@ -11,7 +11,10 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (numerator < denominator ){ + return true; + } + return false; } // The line below allows us to load the isProperFraction function into tests in other files. @@ -30,4 +33,9 @@ function assertEquals(actualOutput, targetOutput) { // What combinations of numerators and denominators should you test? // Example: 1/2 is a proper fraction -assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(3, 2), false); +assertEquals(isProperFraction(2, 2), false); +assertEquals(isProperFraction(3, 4), true); +assertEquals(isProperFraction(5, 3), false); +assertEquals(isProperFraction(0, 5), true); +console.log("✓ All test executed!"); From 468706d48d2f2f321803c311dfe4b0e437adae7b Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 15:55:08 +0000 Subject: [PATCH 05/13] test: enhance isProperFraction function with additional edge cases --- .../implement/2-is-proper-fraction.js | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) 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 056b50560..545f2e4f1 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 @@ -11,10 +11,23 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - if (numerator < denominator ){ - return true; + + if(denominator === 0){ + return false + } + + if (typeof numerator !== "number" || typeof denominator !== "number") { + return false; } - return false; + + if (numerator < 0) { + numerator = numerator * -1; + } + + if (denominator < 0) { + denominator = denominator * -1; + } + return numerator < denominator; } // The line below allows us to load the isProperFraction function into tests in other files. @@ -33,9 +46,18 @@ function assertEquals(actualOutput, targetOutput) { // What combinations of numerators and denominators should you test? // Example: 1/2 is a proper fraction -assertEquals(isProperFraction(3, 2), false); -assertEquals(isProperFraction(2, 2), false); +assertEquals(isProperFraction(5, 9), true); assertEquals(isProperFraction(3, 4), true); -assertEquals(isProperFraction(5, 3), false); +assertEquals(isProperFraction(2, 8), true); +assertEquals(isProperFraction(1, 6), true); assertEquals(isProperFraction(0, 5), true); +assertEquals(isProperFraction(-3, -5), true); + + + +// Example: 3/2 is a improper fraction +assertEquals(isProperFraction(3, 0), false); +assertEquals(isProperFraction(-7, 5), false); +assertEquals(isProperFraction(5, "-36"), false); +assertEquals(isProperFraction("-8", 5), false); console.log("✓ All test executed!"); From 8ebeba790e75e570357fab21f8287712cac8743d Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 15:55:50 +0000 Subject: [PATCH 06/13] test: implement validation checks for card value and suit in getCardValue function --- .../implement/3-get-card-value.js | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 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 c7559e787..f30d5d5c8 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 @@ -22,9 +22,50 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + //check the length and if does not match the valid length throw an error + if (card.length < 2 || card.length > 3) { + throw new Error("Invalid card"); + } "♠"; + const suits = ["♠", "♥", "♦", "♣"]; + const suit = card[card.length - 1]; + + let suitValid = false; + + for(let i = 0; i < suits.length; i++){ + if(suit === suits[i]){ + suitValid = true; + break; + } + } + // after comparing each suit in our array and does not match throw an error + if(suitValid === false){ + throw new Error("Invalid card suit"); + } + + + let rank = card.substring(0, card.length -1); + console.log(rank); + + if (rank === "A") { + return 11; + } + if (rank === "J" || rank === "Q" || rank === "K") { + return 10; + } + + let number = Number(rank); + + if (isNaN(number) || number < 2 || number > 10) { + throw new Error("Invalid card rank"); + } + + return number; } + + + + // The line below allows us to load the getCardValue function into tests in other files. // This will be useful in the "rewrite tests with jest" step. module.exports = getCardValue; @@ -39,7 +80,13 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: -assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("2♠"), 2), true; +assertEquals(getCardValue("d"), d), false; +// assertEquals(getCardValue("10♥"), 10); + + + + // Handling invalid cards try { @@ -47,6 +94,8 @@ try { // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card"); -} catch (e) {} +} catch (e) { + console.log("✓ Error thrown as expected for invalid card"); +} // What other invalid card cases can you think of? From 2a5a3e96f63045ed869f93e99fb9618921ecc3c7 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 16:58:04 +0000 Subject: [PATCH 07/13] test: add assertions and edge case tests for getCardValue function --- .../implement/3-get-card-value.js | 64 ++++++++++++------- 1 file changed, 40 insertions(+), 24 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 f30d5d5c8..ac557150f 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,26 +25,24 @@ function getCardValue(card) { //check the length and if does not match the valid length throw an error if (card.length < 2 || card.length > 3) { throw new Error("Invalid card"); - } "♠"; + } const suits = ["♠", "♥", "♦", "♣"]; const suit = card[card.length - 1]; let suitValid = false; - for(let i = 0; i < suits.length; i++){ - if(suit === suits[i]){ + for (let i = 0; i < suits.length; i++) { + if (suit === suits[i]) { suitValid = true; break; } } // after comparing each suit in our array and does not match throw an error - if(suitValid === false){ + if (suitValid === false) { throw new Error("Invalid card suit"); } - - let rank = card.substring(0, card.length -1); - console.log(rank); + let rank = card.substring(0, card.length - 1); if (rank === "A") { return 11; @@ -54,7 +52,7 @@ function getCardValue(card) { } let number = Number(rank); - + if (isNaN(number) || number < 2 || number > 10) { throw new Error("Invalid card rank"); } @@ -62,31 +60,49 @@ function getCardValue(card) { return number; } - - - - // The line below allows us to load the getCardValue function into tests in other files. // This will be useful in the "rewrite tests with jest" step. module.exports = getCardValue; // Helper functions to make our assertions easier to read. function assertEquals(actualOutput, targetOutput) { - console.assert( - actualOutput === targetOutput, - `Expected ${actualOutput} to equal ${targetOutput}` - ); + if (actualOutput !== targetOutput) { + console.error( + `❌ FAILED: Expected ${targetOutput} but received ${actualOutput}` + ); + } else { + console.log(`✅ PASSED: Value is ${actualOutput} as expected`); + } +} + +function assertThrows(invalidCard) { + try { + getCardValue(invalidCard); + console.error( + `❌ FAILED: "${invalidCard}" should have thrown an error, but it didn't` + ); + } catch (e) { + console.log(`✅ PASSED: Error catch para "${invalidCard}" [${e.message}]`); + } } // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: -assertEquals(getCardValue("2♠"), 2), true; -assertEquals(getCardValue("d"), d), false; -// assertEquals(getCardValue("10♥"), 10); - - - - +console.log("--- Running Success Tests ---"); +assertEquals(getCardValue("2♠"), 2); +assertEquals(getCardValue("10♥"), 10); +assertEquals(getCardValue("A♣"), 11); +assertEquals(getCardValue("K♦"), 10); +assertEquals(getCardValue("J♠"), 10); +assertEquals(getCardValue("Q♥"), 10); +assertEquals(getCardValue("7♦"), 7); + +console.log("\n--- Running Edge Case Tests ---"); +assertThrows("d"); +assertThrows("15♥"); +assertThrows("A"); +assertThrows("JPP"); +assertThrows("Q🌸"); // Handling invalid cards try { @@ -94,7 +110,7 @@ try { // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card"); -} catch (e) { +} catch (e) { console.log("✓ Error thrown as expected for invalid card"); } From 91cf155203dbf266b78dc60c1efa844345bfac4f Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 18:13:32 +0000 Subject: [PATCH 08/13] Co-authored-by: RahwaZeslusHaile Co-authored-by: Angela McLeary Co-authored-by: Mohsen Zamanist --- .../1-get-angle-type.test.js | 29 +++++++++++++++++++ 1 file changed, 29 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 d777f348d..26464620e 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 @@ -13,8 +13,37 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { expect(getAngleType(89)).toEqual("Acute angle"); }); + // Case 2: Right angle +test(`should return "Right angle" when (angle = 90)`, () => { + expect(getAngleType(90)).toEqual("Right angle"); +}); + + // Case 3: Obtuse angles +test(`Should return "Obtuse angle" when the (angle > 90 && angle < 180)`, () => { + expect(getAngleType(160)).toEqual("Obtuse angle"); + expect(getAngleType(110)) .toEqual("Obtuse angle"); + expect(getAngleType(140)).toEqual("Obtuse angle"); +}); // Case 4: Straight angle +test(`should return "Straight angle" when (angle == 180)`, () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); // Case 5: Reflex angles +test('should return "Reflex angle" when (angle > 180 && angle < 360)',()=>{ + expect(getAngleType(181)).toBe("Reflex angle"); + expect(getAngleType(270)).toBe("Reflex angle"); + expect(getAngleType(300)).toBe("Reflex angle"); + +}); + // Case 6: Invalid angles +test(`Should return "Invalid angle" when the input is invalid`, () => { + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); + expect(getAngleType(400)).toEqual("Invalid angle"); +}); + + From f49cc6fcd3fba91440788642e8fa0111c0bacd96 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 22:25:36 +0000 Subject: [PATCH 09/13] fix: remove unnecessary line breaks in calculateBMI function --- Sprint-2/3-mandatory-implement/1-bmi.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 1825ca005..17b1cbde1 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -16,8 +16,4 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height -} - - - -// update the code below to test your function with different inputs \ No newline at end of file +} \ No newline at end of file From 580d40f2cecd5beae6c7c4bf8ac45634b2f6c374 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 22:57:59 +0000 Subject: [PATCH 10/13] test: refactor angle type tests for consistency and readability --- .../1-get-angle-type.test.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 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 26464620e..6717783e1 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 @@ -13,29 +13,28 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { expect(getAngleType(89)).toEqual("Acute angle"); }); - // Case 2: Right angle test(`should return "Right angle" when (angle = 90)`, () => { expect(getAngleType(90)).toEqual("Right angle"); }); - // Case 3: Obtuse angles test(`Should return "Obtuse angle" when the (angle > 90 && angle < 180)`, () => { expect(getAngleType(160)).toEqual("Obtuse angle"); - expect(getAngleType(110)) .toEqual("Obtuse angle"); + expect(getAngleType(110)).toEqual("Obtuse angle"); expect(getAngleType(140)).toEqual("Obtuse angle"); }); + // Case 4: Straight angle test(`should return "Straight angle" when (angle == 180)`, () => { expect(getAngleType(180)).toEqual("Straight angle"); }); + // Case 5: Reflex angles -test('should return "Reflex angle" when (angle > 180 && angle < 360)',()=>{ +test('should return "Reflex angle" when (angle > 180 && angle < 360)', () => { expect(getAngleType(181)).toBe("Reflex angle"); - expect(getAngleType(270)).toBe("Reflex angle"); + expect(getAngleType(270)).toBe("Reflex angle"); expect(getAngleType(300)).toBe("Reflex angle"); - }); // Case 6: Invalid angles @@ -45,5 +44,3 @@ test(`Should return "Invalid angle" when the input is invalid`, () => { expect(getAngleType(361)).toEqual("Invalid angle"); expect(getAngleType(400)).toEqual("Invalid angle"); }); - - From b8ab5928fbbf1088f574a21b91c599516074dc71 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 23:33:24 +0000 Subject: [PATCH 11/13] test: enhance isProperFraction function to handle zero numerator and denominator cases --- .../implement/2-is-proper-fraction.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 545f2e4f1..df73baf47 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,14 +12,10 @@ function isProperFraction(numerator, denominator) { - if(denominator === 0){ + if(denominator === 0 || numerator === 0){ return false } - if (typeof numerator !== "number" || typeof denominator !== "number") { - return false; - } - if (numerator < 0) { numerator = numerator * -1; } @@ -58,6 +54,4 @@ assertEquals(isProperFraction(-3, -5), true); // Example: 3/2 is a improper fraction assertEquals(isProperFraction(3, 0), false); assertEquals(isProperFraction(-7, 5), false); -assertEquals(isProperFraction(5, "-36"), false); -assertEquals(isProperFraction("-8", 5), false); console.log("✓ All test executed!"); From 7d6cba2e57072c8c495f1ee749bc53d851246c3d Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Feb 2026 23:33:43 +0000 Subject: [PATCH 12/13] test: expand isProperFraction tests to cover all edge cases and scenarios --- .../2-is-proper-fraction.test.js | 25 ++++++++++++++++--- 1 file changed, 22 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 7f087b2ba..f78ccc225 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,26 @@ 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`, () => { - expect(isProperFraction(1, 0)).toEqual(false); +// test: proper fraction +// --- case 1: Proper Fractions --- +test('should return true for valid proper fractions, including negative numbers', () => { + expect(isProperFraction(5, 9)).toBe(true); + expect(isProperFraction(3, 4)).toBe(true); + expect(isProperFraction(2, 8)).toBe(true); + expect(isProperFraction(1, 6)).toBe(true); + expect(isProperFraction(-3, -5)).toBe(true); }); + +// --- case 2: Improper Fractions --- +test('should return false for improper fractions where numerator >= denominator', () => { + expect(isProperFraction(-7, 5)).toBe(false); + expect(isProperFraction(10, 3)).toBe(false); + expect(isProperFraction(5, 5)).toBe(false); +}); + +// --- case 3: 0 Numerator and 0 Denominator --- +test('should return false when numerator or denominator is zero', () => { + expect(isProperFraction(3, 0)).toBe(false); + expect(isProperFraction(0, 3)).toBe(false); + expect(isProperFraction(0, 0)).toBe(false); +}); \ No newline at end of file From 4bec805b1692021f91b3e82f5a9952127ec7442d Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 24 Feb 2026 15:59:01 +0000 Subject: [PATCH 13/13] test: rewrite and expand tests for getCardValue function with success and error cases --- .../3-get-card-value.test.js | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 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 cf7f9dae2..3540c8240 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 @@ -4,11 +4,6 @@ const getCardValue = require("../implement/3-get-card-value"); // TODO: Write tests in Jest syntax to cover all possible outcomes. -// Case 1: Ace (A) -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) // Face Cards (J, Q, K) @@ -18,3 +13,43 @@ test(`Should return 11 when given an ace card`, () => { // please refer to the Jest documentation: // https://jestjs.io/docs/expect#tothrowerror +describe("getCardValue", () => { + + // Group 1: success cases (Valid cards) + test("should return 11 when given an Ace (A)", () => { + expect(getCardValue("A♠")).toBe(11); + expect(getCardValue("A♥")).toBe(11); + }); + + test("should return 10 when given a face card (J, Q, K)", () => { + expect(getCardValue("J♣")).toBe(10); + expect(getCardValue("Q♦")).toBe(10); + expect(getCardValue("K♠")).toBe(10); + }); + + test("should return the numeric value for number cards (2-10)", () => { + expect(getCardValue("2♥")).toBe(2); + expect(getCardValue("7♦")).toBe(7); + expect(getCardValue("10♣")).toBe(10); + }); + + // Group 2: error cases (Invalid cards) + describe("Invalid cards", () => { + test("should throw an error for invalid card length or missing components", () => { + expect(() => getCardValue("A")).toThrow("Invalid card"); + expect(() => getCardValue("100♥")).toThrow("Invalid card"); + expect(() => getCardValue("")).toThrow("Invalid card"); + }); + + test("should throw an error for an invalid suit emoji", () => { + expect(() => getCardValue("A🌸")).toThrow("Invalid card suit"); + expect(() => getCardValue("10X")).toThrow("Invalid card suit"); + }); + + test("should throw an error for an invalid rank", () => { + expect(() => getCardValue("1♥")).toThrow("Invalid card rank"); + expect(() => getCardValue("15♦")).toThrow("Invalid card rank"); + expect(() => getCardValue("Z♠")).toThrow("Invalid card rank"); + }); + }); +});