From c83ad2fa105ec46b8450240325be53f0668061ae Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 12:21:46 +0000 Subject: [PATCH 01/10] Done the implement and rewrite --- .../implement/1-get-angle-type.js | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 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 9e05a871e2..a01610010c 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 @@ -1,5 +1,4 @@ // Implement a function getAngleType -// // When given an angle in degrees, it should return a string indicating the type of angle: // - "Acute angle" for angles greater than 0° and less than 90° // - "Right angle" for exactly 90° @@ -15,12 +14,34 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + function getAngleType(angle) { + if (angle <= 0 || angle >= 360) + } + + if (angle < 90) { + return "acute angle"; + } + if (angle === 90) { + return "right angle"; + } + if (angle < 180){ + return "obtuse angle"; + } + if (angle === 180){ + return "straight angle"; + } +if (angle < 360){ + return "reflex angle"; } +module.exports = getAngleType; + + + // TODO: Implement this function + // The line below allows us to load the getAngleType function into tests in other files. // This will be useful in the "rewrite tests with jest" step. -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 @@ -35,3 +56,11 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + + // Test +assertEquals(getAngleType(45), "Acute angle"); +assertEquals(getAngleType(90), "Right angle"); +assertEquals(getAngleType(120), "Obtuse angle"); +assertEquals(getAngleType(180), "Straight angle"); +assertEquals(getAngleType(270), "Reflex angle"); +assertEquals(getAngleType(390), "Invalid angle"); From 95a7938a8bda1d1761c7d65f64551683b3512bcd Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 13:56:19 +0000 Subject: [PATCH 02/10] Done the Implement and rewrite --- .../implement/1-get-angle-type.js | 38 +++++++++---------- .../implement/2-is-proper-fraction.js | 24 +++++++++--- .../implement/3-get-card-value.js | 26 +++++++++++-- 3 files changed, 60 insertions(+), 28 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 a01610010c..55b459f74e 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 @@ -14,35 +14,33 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - function getAngleType(angle) { - if (angle <= 0 || angle >= 360) - } + if (angle <= 0 || angle >= 360) { + return "Invalid angle"; + } if (angle < 90) { - return "acute angle"; + return "Acute angle"; + } + if (angle === 90) { + return "Right angle"; + } + if (angle < 180) { + return "Obtuse angle"; + } + if (angle === 180) { + return "Straight angle"; + } + if (angle < 360) { + return "Reflex angle"; } - if (angle === 90) { - return "right angle"; - } - if (angle < 180){ - return "obtuse angle"; - } - if (angle === 180){ - return "straight angle"; - } -if (angle < 360){ - return "reflex angle"; } module.exports = getAngleType; - - // TODO: Implement this function - +// TODO: Implement this function // The line below allows us to load the getAngleType function into tests in other files. // This will be useful in the "rewrite tests with jest" step. - // 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) { @@ -57,7 +55,7 @@ function assertEquals(actualOutput, targetOutput) { const right = getAngleType(90); assertEquals(right, "Right angle"); - // Test +// Test assertEquals(getAngleType(45), "Acute angle"); assertEquals(getAngleType(90), "Right angle"); assertEquals(getAngleType(120), "Obtuse 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 970cb9b641..d93d7b611f 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,23 +11,37 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + return numerator < denominator; } // The line below allows us to load the isProperFraction function into tests in other files. // This will be useful in the "rewrite tests with jest" step. -module.exports = isProperFraction; -// Here's our helper again +// Here's our hel per again function assertEquals(actualOutput, targetOutput) { console.assert( actualOutput === targetOutput, `Expected ${actualOutput} to equal ${targetOutput}` ); } +module.exports = isProperFraction; // TODO: Write tests to cover all cases. // What combinations of numerators and denominators should you test? -// Example: 1/2 is a proper fraction -assertEquals(isProperFraction(1, 2), true); +//Test +// Proper fraction +assertEquals(isProperFraction(3, 5), true); +assertEquals(isProperFraction(4, 8), true); +assertEquals(isProperFraction(-1, 2), true); +assertEquals(isProperFraction(-1, -2), true); +assertEquals(isProperFraction(1, -2), true); + +//Not +assertEquals(isProperFraction(9, 7), false); +assertEquals(isProperFraction(13, 11), false); +assertEquals(isProperFraction(19, 10), false); +assertEquals(isProperFraction(17, 3), false); + +//Edge case +assertEquals(isProperFraction(0, 5), true); 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..9aaf5241e0 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,12 +22,27 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + const rank = card.slice(0, -1); + const suit = card.slice(-1); + +const vaildSuits = ["♠", "♥", "♦", "♣"]; + const vailRanks = ["A","2","3","4","5","6","7","8","9","10","J","Q","k"]; + + if (!vaildSuits.includes(suit) || !validRanks.inculdes(rank)){ + throw new Error("Invaild card"); + } + if (rank === "A") return 11; + if (rank === "J" || rank === "Q" || rank === "K") return 10; + + return Number(rank); } +module.exports = getCardValue; + + // 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) { @@ -40,13 +55,18 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: assertEquals(getCardValue("9♠"), 9); +//Test +assertEquals(getCardvalue("A♠"), 11); +assertEquals(getCardEqual("J♣), 10); +assertEquals(getCardequal("10♥"), 10); // Handling invalid cards try { getCardValue("invalid"); + // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card"); } catch (e) {} -// What other invalid card cases can you think of? +// What other invalid card cases can you think of? \ No newline at end of file From c94ac7b8dcf82d66c84ab4ac1f116ca98dfab97c Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 14:15:06 +0000 Subject: [PATCH 03/10] fixed error --- .../implement/3-get-card-value.js | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 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 9aaf5241e0..f6b0b1e5c1 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,11 +25,25 @@ function getCardValue(card) { const rank = card.slice(0, -1); const suit = card.slice(-1); -const vaildSuits = ["♠", "♥", "♦", "♣"]; - const vailRanks = ["A","2","3","4","5","6","7","8","9","10","J","Q","k"]; - - if (!vaildSuits.includes(suit) || !validRanks.inculdes(rank)){ - throw new Error("Invaild card"); + const vaildSuits = ["♠", "♥", "♦", "♣"]; + const vailRanks = [ + "A", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "J", + "Q", + "K", + ]; + + if (!vaildSuits.includes(suit) || !vailRanks.includes(rank)) { + throw new Error("Invalid card"); } if (rank === "A") return 11; if (rank === "J" || rank === "Q" || rank === "K") return 10; @@ -39,11 +53,9 @@ const vaildSuits = ["♠", "♥", "♦", "♣"]; module.exports = getCardValue; - // 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. - // Helper functions to make our assertions easier to read. function assertEquals(actualOutput, targetOutput) { console.assert( @@ -56,17 +68,16 @@ function assertEquals(actualOutput, targetOutput) { // Examples: assertEquals(getCardValue("9♠"), 9); //Test -assertEquals(getCardvalue("A♠"), 11); -assertEquals(getCardEqual("J♣), 10); -assertEquals(getCardequal("10♥"), 10); +assertEquals(getCardValue("A♠"), 11); +assertEquals(getCardValue("J♣"), 10); +assertEquals(getCardValue("10♥"), 10); // Handling invalid cards try { getCardValue("invalid"); - // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card"); } catch (e) {} -// What other invalid card cases can you think of? \ No newline at end of file +// What other invalid card cases can you think of? From 69bef1b39848af4a5b77ce035ea3013049fe9ee4 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 14:25:09 +0000 Subject: [PATCH 04/10] correct an issue --- .../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 f6b0b1e5c1..f3bb45a9aa 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 @@ -51,7 +51,7 @@ function getCardValue(card) { return Number(rank); } -module.exports = getCardValue; +export default getCardValue; // 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. From ebe03047a63517649c7e3f8724e123fb6b4aa2ae Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 26 Mar 2026 15:13:38 +0000 Subject: [PATCH 05/10] Added getCardValue function logic --- .../implement/2-is-proper-fraction.js | 24 ++++++------ .../implement/3-get-card-value.js | 39 ++++++++++++++----- 2 files changed, 42 insertions(+), 21 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 d93d7b611f..f429688f18 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,9 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - return numerator < denominator; + if (denominator === 0) return false; + + return Math.abs(numerator) < Math.abs(denominator); } // The line below allows us to load the isProperFraction function into tests in other files. @@ -30,18 +32,18 @@ module.exports = isProperFraction; // What combinations of numerators and denominators should you test? //Test -// Proper fraction -assertEquals(isProperFraction(3, 5), true); -assertEquals(isProperFraction(4, 8), true); -assertEquals(isProperFraction(-1, 2), true); +// Proper fraction with negatives +assertEquals(isProperFraction(7, 9), true); +assertEquals(isProperFraction(-7, 9), true); +assertEquals(isProperFraction(7, -9), true); assertEquals(isProperFraction(-1, -2), true); -assertEquals(isProperFraction(1, -2), true); +assertEquals(isProperFraction(0, -5), true); -//Not -assertEquals(isProperFraction(9, 7), false); -assertEquals(isProperFraction(13, 11), false); -assertEquals(isProperFraction(19, 10), false); +// Improper fractions +assertEquals(isProperFraction(9, -7), false); +assertEquals(isProperFraction(-9, 7), false); +assertEquals(isProperFraction(-9, -7), false); assertEquals(isProperFraction(17, 3), false); //Edge case -assertEquals(isProperFraction(0, 5), true); +assertEquals(isProperFraction(1, 0), false); 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 f3bb45a9aa..f942363660 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,11 +22,14 @@ // execute the code to ensure all tests pass. function getCardValue(card) { + if (!card || typeof card !== "string") { + throw new Error("Invalid card"); + } const rank = card.slice(0, -1); const suit = card.slice(-1); - const vaildSuits = ["♠", "♥", "♦", "♣"]; - const vailRanks = [ + const validSuits = ["♠", "♥", "♦", "♣"]; + const validRanks = [ "A", "2", "3", @@ -42,7 +45,7 @@ function getCardValue(card) { "K", ]; - if (!vaildSuits.includes(suit) || !vailRanks.includes(rank)) { + if (!validSuits.includes(suit) || !validRanks.includes(rank)) { throw new Error("Invalid card"); } if (rank === "A") return 11; @@ -66,18 +69,34 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: + +// Valid cards assertEquals(getCardValue("9♠"), 9); -//Test assertEquals(getCardValue("A♠"), 11); assertEquals(getCardValue("J♣"), 10); assertEquals(getCardValue("10♥"), 10); -// Handling invalid cards + + +// What other invalid card cases can you think of? + +// Invalid cases try { getCardValue("invalid"); + console.log("fail invalid"); +} catch (e) { + console.log("pass invalid"); +} - // This line will not be reached if an error is thrown as expected - console.error("Error was not thrown for invalid card"); -} catch (e) {} - -// What other invalid card cases can you think of? +try { + getCardValue("1♠"); + console.log("fail 1♠"); +} catch (e) { + console.log("pass 1♠"); +} +try { + getCardValue("A"); + console.log("fail A"); +} catch (e) { + console.log("pass A"); +} \ No newline at end of file From 05ff81dccd964e7ba7db185b6081aae82f3b5d80 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 26 Mar 2026 15:14:52 +0000 Subject: [PATCH 06/10] Saved some changes --- .../implement/3-get-card-value.js | 4 +--- 1 file changed, 1 insertion(+), 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 f942363660..f1d4d29e7d 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 @@ -76,8 +76,6 @@ assertEquals(getCardValue("A♠"), 11); assertEquals(getCardValue("J♣"), 10); assertEquals(getCardValue("10♥"), 10); - - // What other invalid card cases can you think of? // Invalid cases @@ -99,4 +97,4 @@ try { console.log("fail A"); } catch (e) { console.log("pass A"); -} \ No newline at end of file +} From 459fc1f06438910e8809e720e2a60e08abd765ad Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 26 Mar 2026 21:27:41 +0000 Subject: [PATCH 07/10] Tested the angle type with jest --- .../1-get-angle-type.test.js | 22 +++++++++++++++++++ 1 file changed, 22 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..6daa10fc56 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,29 @@ 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(0)).toEqual("Invalid angle"); + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); From 2bc76dd1afeb83b278b0ddd5284d5d43fcc0ce95 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 26 Mar 2026 22:18:02 +0000 Subject: [PATCH 08/10] Testing the proper fraction with Jest --- .../2-is-proper-fraction.test.js | 32 ++++++++++++++++++- 1 file changed, 31 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..6b0c8aa4bc 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,37 @@ 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 test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +// Special case: numerator is zero +test(`should return true when numerator is zero`, () => { + expect(isProperFraction(0, 5)).toEqual(true); +}); + +// Special case: positive numerator and denominator +test(`should return true when numerator is less than denominator`, () => { + expect(isProperFraction(7, 9)).toEqual(true); +}); + +// Special case; negative numerator and positive denominatore +test(` should return true when numertaor is negative and less than demoniator`, () => { + expect(isproperFraction(-5, 9)).toEuqal(true); +}); + +// special case: postive numerator and negative deminator +test(`should return true when numerator is positive and less than denominator`, () => { + expect(isProperFraction(5, -7)).toEqual(true); +}); + +// Special case: negative numerator and negative denominator +test(`should return true when both are negative`, () => { + expect(isProperFraction(-5, -7)).toEqual(true); +}); + +// Special case: Equal values +test(`should return true when numerator and denominator are equal`, () => { + expect(isProperFraction(5, 5)).toEqual(true); +}); From 36150a850c2c651f7a5b10ff990549bf1e4ece05 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 26 Mar 2026 22:21:34 +0000 Subject: [PATCH 09/10] Fixed spelling mistakes --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 6 +++--- 1 file changed, 3 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 6b0c8aa4bc..43e73538d9 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 @@ -21,7 +21,7 @@ test(`should return true when numerator is less than denominator`, () => { // Special case; negative numerator and positive denominatore test(` should return true when numertaor is negative and less than demoniator`, () => { - expect(isproperFraction(-5, 9)).toEuqal(true); + expect(isProperFraction(-5, 9)).toEqual(true); }); // special case: postive numerator and negative deminator @@ -35,6 +35,6 @@ test(`should return true when both are negative`, () => { }); // Special case: Equal values -test(`should return true when numerator and denominator are equal`, () => { - expect(isProperFraction(5, 5)).toEqual(true); +test(`should return false when numerator and denominator are equal`, () => { + expect(isProperFraction(5, 5)).toEqual(false); }); From 20e062b893b43b38eab4a652264a325b18996503 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Fri, 27 Mar 2026 12:39:39 +0000 Subject: [PATCH 10/10] Aded jest test for getCardValue function --- .../2-is-proper-fraction.test.js | 8 +++---- .../3-get-card-value.test.js | 24 +++++++++++++++++-- 2 files changed, 26 insertions(+), 6 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 43e73538d9..7d4f02b604 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 @@ -16,7 +16,7 @@ test(`should return true when numerator is zero`, () => { // Special case: positive numerator and denominator test(`should return true when numerator is less than denominator`, () => { - expect(isProperFraction(7, 9)).toEqual(true); + expect(isProperFraction(5, 9)).toEqual(true); }); // Special case; negative numerator and positive denominatore @@ -26,15 +26,15 @@ test(` should return true when numertaor is negative and less than demoniator`, // special case: postive numerator and negative deminator test(`should return true when numerator is positive and less than denominator`, () => { - expect(isProperFraction(5, -7)).toEqual(true); + expect(isProperFraction(5, -9)).toEqual(true); }); // Special case: negative numerator and negative denominator test(`should return true when both are negative`, () => { - expect(isProperFraction(-5, -7)).toEqual(true); + expect(isProperFraction(-5, -9)).toEqual(true); }); // Special case: Equal values test(`should return false when numerator and denominator are equal`, () => { - expect(isProperFraction(5, 5)).toEqual(false); + expect(isProperFraction(4, 4)).toEqual(false); }); 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..06670bec39 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 @@ -5,16 +5,36 @@ 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`, () => { +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 the correct value for number cards`, () => { + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("10♣")).toEqual(10); + expect(getCardValue("6♥")).toEqual(6); + expect(getCardValue("9♦")).toEqual(9); + expect(getCardValue("3♠")).toEqual(3); +}); // Face Cards (J, Q, K) +test(`should return the correct value for face cards`, () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♠")).toEqual(10); + expect(getCardValue("K♠")).toEqual(10); +}); // Invalid Cards +test("should throw error for invalid cards", () => { + expect(() => getCardValue("1♠")).toThrow(); + expect(() => getCardValue("11♠")).toThrow(); + expect(() => getCardValue("Z♠")).toThrow(); + expect(() => getCardValue("A")).toThrow(); + expect(() => getCardValue("♠")).toThrow(); + expect(() => getCardValue("")).toThrow(); + expect(() => getCardValue(null)).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 -