From dcf9e965e23e3d77e157cb66ce60c33bebb76de3 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Tue, 23 Jun 2026 07:04:36 +0100 Subject: [PATCH 01/14] write tests for 1-implement-and-rewrite-tests/implement/1-get-angle-type.js --- .../implement/1-get-angle-type.js | 11 +++++++++++ 1 file changed, 11 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..0cc87ca978 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 @@ -34,4 +34,15 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles const right = getAngleType(90); +const acute = getAngleType(75); +const obtuse = getAngleType(150); +const straight = getAngleType(180); +const reflex = getAngleType(340); +const invalid = getAngleType(-5); + assertEquals(right, "Right angle"); +assertEquals(acute, "Acute angle"); +assertEquals(obtuse, "Obtuse angle"); +assertEquals(straight, "Straight angle"); +assertEquals(reflex, "Reflex angle"); +assertEquals(invalid, "Invalid angle"); From f83d840426598f0cb1278f12474237c571c73af0 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Tue, 23 Jun 2026 07:37:46 +0100 Subject: [PATCH 02/14] Confirm that all assert tests pass for 1-implement-and-rewrite-tests/implement/1-get-angle-type.js --- .../implement/1-get-angle-type.js | 19 ++++++++++++++++++- 1 file changed, 18 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 0cc87ca978..1439c70d10 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,21 @@ function getAngleType(angle) { // TODO: Implement this function + let returnAngle; + if (angle > 0 && angle < 90) { + returnAngle = "Acute"; + } else if (angle === 90) { + returnAngle = "Right"; + } else if (angle > 90 && angle < 180) { + returnAngle = "Obtuse"; + } else if (angle === 180) { + returnAngle = "Straight"; + } else if (angle > 180 && angle < 360) { + returnAngle = "Reflex"; + } else { + returnAngle = "Invalid"; + } + return `${returnAngle} angle`; } // The line below allows us to load the getAngleType function into tests in other files. @@ -38,7 +53,9 @@ const acute = getAngleType(75); const obtuse = getAngleType(150); const straight = getAngleType(180); const reflex = getAngleType(340); -const invalid = getAngleType(-5); +let invalid = getAngleType(0); +invalid = getAngleType(360); +invalid = getAngleType(-2); assertEquals(right, "Right angle"); assertEquals(acute, "Acute angle"); From d9144d9c3f82f9943dd399c4edd806e67fa0b487 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Tue, 23 Jun 2026 07:52:49 +0100 Subject: [PATCH 03/14] write tests for 1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js --- .../implement/2-is-proper-fraction.js | 5 +++++ 1 file changed, 5 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..6c28389150 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 @@ -31,3 +31,8 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(3, 1), false); +assertEquals(isProperFraction(2, 2), false); +assertEquals(isProperFraction(5, 0), false); +assertEquals(isProperFraction(-2, 4), true); +assertEquals(isProperFraction(4, -2), false); From 0bfbb21a07834676c1f2d5b4b07eb60a2d9f4686 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Tue, 23 Jun 2026 07:59:29 +0100 Subject: [PATCH 04/14] Execute code to ensure all tests pass in 1-implement-and-rewrite-test/implement/2-is-proper-fraction.js --- .../implement/2-is-proper-fraction.js | 2 ++ 1 file changed, 2 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 6c28389150..188b4c92d3 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,8 @@ function isProperFraction(numerator, denominator) { // TODO: Implement this function + 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. From 3780aff480788c1d009ad15dffc937e8723eddb8 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Tue, 23 Jun 2026 08:03:07 +0100 Subject: [PATCH 05/14] Add additional test and check it passes to 1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js --- .../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 188b4c92d3..d2b69b0970 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 @@ -36,5 +36,6 @@ assertEquals(isProperFraction(1, 2), true); assertEquals(isProperFraction(3, 1), false); assertEquals(isProperFraction(2, 2), false); assertEquals(isProperFraction(5, 0), false); +assertEquals(isProperFraction(-1, 0), false); assertEquals(isProperFraction(-2, 4), true); assertEquals(isProperFraction(4, -2), false); From 49049fe61846c64059116938bc4e50a0fc62dc40 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Tue, 23 Jun 2026 09:15:53 +0100 Subject: [PATCH 06/14] write tests for 1-implement-and-rewrite-tests/implement/3-get-card-value.js --- .../implement/3-get-card-value.js | 14 ++++++++++++++ 1 file changed, 14 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..f650953c81 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,14 @@ function getCardValue(card) { // TODO: Implement this function + const ranks = "A,2,3,4,5,6,7,8,9,10,J,Q,K".split(","); + const suites = "♠,♥,♦,♣".split(","); + const validCards = new Set(); + for (const rank of ranks) { + for (const suite of suites) { + validCards.add(rank + suite); + } + } } // The line below allows us to load the getCardValue function into tests in other files. @@ -40,6 +48,12 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("A"), 11); +assertEquals(getCardValue("Q"), 10); +assertEquals(getCardValue("5"), 5); +assertEquals(getCardValue(true), "invalid"); +assertEquals(getCardValue("A♠"), 11); +// assertEquals(getCardValue("invalid"), 9); // Handling invalid cards try { From e82177d634d60725cab8b57686a8a6fc757a0ffc Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Wed, 24 Jun 2026 17:34:38 +0100 Subject: [PATCH 07/14] Write tests for 1-implement-and-rewrite-tests/implement/3-get-card-value.js --- .../implement/3-get-card-value.js | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 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 f650953c81..f1676a380e 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 @@ -20,9 +20,7 @@ // Acceptance criteria: // After you have implemented the function, write tests to cover all the cases, and // execute the code to ensure all tests pass. - -function getCardValue(card) { - // TODO: Implement this function +function generateValidCards() { const ranks = "A,2,3,4,5,6,7,8,9,10,J,Q,K".split(","); const suites = "♠,♥,♦,♣".split(","); const validCards = new Set(); @@ -31,6 +29,20 @@ function getCardValue(card) { validCards.add(rank + suite); } } + return validCards; +} + +function getCardValue(card) { + // TODO: Implement this function + const validCards = generateValidCards(); + if (!validCards.has(card)) { + throw new Error("invalid"); + } + + let cardValue = card.slice(0, -1); + if (cardValue === "A") return 11; + if (cardValue === "J" || cardValue === "Q" || cardValue === "K") return 10; + return Number(cardValue); } // The line below allows us to load the getCardValue function into tests in other files. @@ -38,31 +50,26 @@ function getCardValue(card) { 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}` - ); +function assertEquals(card, targetOutput) { + try { + const actualOutput = getCardValue(card); + console.assert( + actualOutput === targetOutput, + `Expected ${actualOutput} to equal ${targetOutput}` + ); + console.error("Error was not thrown for invalid card 😢"); + } catch (e) { + console.log("Error thrown for invalid card 🎉"); + } + console.log("-".repeat(45)); } // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. -// Examples: -assertEquals(getCardValue("9♠"), 9); -assertEquals(getCardValue("A"), 11); -assertEquals(getCardValue("Q"), 10); -assertEquals(getCardValue("5"), 5); -assertEquals(getCardValue(true), "invalid"); -assertEquals(getCardValue("A♠"), 11); -// assertEquals(getCardValue("invalid"), 9); - -// 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) { - console.log("Error thrown for invalid card 🎉"); -} -// What other invalid card cases can you think of? +assertEquals("9♠", 9); +assertEquals("A", 11); +assertEquals("Q", 10); +assertEquals("5", 5); +assertEquals("A♣", 11); +assertEquals("Q♣", 11); +assertEquals("A♦", 10); From 1d526db76de618c55d856dd23a885c6ad4aca734 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Thu, 25 Jun 2026 08:59:11 +0100 Subject: [PATCH 08/14] Update answer to 1-implement-and-rewrite-tests/implement/3-get-card-value.js --- .../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 f1676a380e..14761b02aa 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 @@ -52,6 +52,7 @@ module.exports = getCardValue; // Helper functions to make our assertions easier to read. function assertEquals(card, targetOutput) { try { + console.log(`Card: ${card}`); const actualOutput = getCardValue(card); console.assert( actualOutput === targetOutput, @@ -65,7 +66,6 @@ function assertEquals(card, targetOutput) { } // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. - assertEquals("9♠", 9); assertEquals("A", 11); assertEquals("Q", 10); From 788b6626bb396455dcce80ba63a206e5205dab01 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Thu, 25 Jun 2026 09:40:21 +0100 Subject: [PATCH 09/14] Add jest to package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 e346b17420c6991f9fb87be1823f5cace328f687 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Thu, 25 Jun 2026 09:57:55 +0100 Subject: [PATCH 10/14] Write jest tests for 1-get-angle-type.test.js --- .../1-get-angle-type.test.js | 21 +++++++++++++++++++ 1 file changed, 21 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..95c5cab8fd 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,28 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // 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 (90 < angle < 180)`, () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(120)).toEqual("Obtuse angle"); + expect(getAngleType(179)).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 (180 < angle < 360)`, () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(340)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); // Case 6: Invalid angles +test(`should return "Invalid" when (angle < 1 || angel > 360)`, () => { + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(-15)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); From 163c1d0e29f16fe10bdaf1b899cf7b839d27e9af Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Thu, 25 Jun 2026 10:33:44 +0100 Subject: [PATCH 11/14] Write jest tests for 2-is-proper-fraction.test.js --- .../2-is-proper-fraction.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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..85201d254b 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 @@ -8,3 +8,13 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +test(`should return false when (numerator >= denominator)`, () => { + expect(isProperFraction(2, 1)).toEqual(false); + expect(isProperFraction(2, 2)).toEqual(false); +}); + +test(`should treat numerator and denominator as absolute values when determining proper fractions`, () => { + expect(isProperFraction(-2, 3)).toEqual(true); + expect(isProperFraction(-7, 2)).toEqual(false); +}); From bae2cd3c5e63103d3e728a233d839565aeb936fe Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Fri, 26 Jun 2026 10:37:42 +0100 Subject: [PATCH 12/14] Update 1-implment-and-rewrite-tests/implement/3-get-card-value.js --- .../implement/3-get-card-value.js | 94 ++++++++++++------- .../3-get-card-value.test.js | 19 +++- 2 files changed, 78 insertions(+), 35 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 14761b02aa..92a6416e0a 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 @@ -20,29 +20,31 @@ // Acceptance criteria: // After you have implemented the function, write tests to cover all the cases, and // execute the code to ensure all tests pass. -function generateValidCards() { - const ranks = "A,2,3,4,5,6,7,8,9,10,J,Q,K".split(","); - const suites = "♠,♥,♦,♣".split(","); - const validCards = new Set(); - for (const rank of ranks) { - for (const suite of suites) { - validCards.add(rank + suite); - } - } - return validCards; -} function getCardValue(card) { // TODO: Implement this function - const validCards = generateValidCards(); - if (!validCards.has(card)) { - throw new Error("invalid"); + const cardRanks = "A,2,3,4,5,6,7,8,9,10,J,Q,K".split(","); + const cardSuits = "♠,♥,♦,♣".split(","); + + // Throw error if card is empty + if (!card) throw new Error(`Invalid card`); + + const cardSuit = card[card.length - 1]; + // Throw error is card suit is not valid + if (!cardSuits.includes(cardSuit)) { + throw new Error(`Invalid card suit`); } - let cardValue = card.slice(0, -1); - if (cardValue === "A") return 11; - if (cardValue === "J" || cardValue === "Q" || cardValue === "K") return 10; - return Number(cardValue); + const cardRank = card.slice(0, -1); + // Throw error is cardRank is not valid + if (!cardRanks.includes(cardRank)) { + throw new Error(`Invalid card rank`); + } + + // Return the card value based on given rank + if (cardRank === "A") return 11; + if (["J", "Q", "K"].includes(cardRank)) return 10; + return Number(cardRank); } // The line below allows us to load the getCardValue function into tests in other files. @@ -50,26 +52,50 @@ function getCardValue(card) { module.exports = getCardValue; // Helper functions to make our assertions easier to read. -function assertEquals(card, targetOutput) { +function assertEquals(actualOutput, targetOutput) { + console.assert( + actualOutput === targetOutput, + `Expected ${actualOutput} to equal ${targetOutput}` + ); +} + +// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. +// Examples: +assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("J♥"), 10); +assertEquals(getCardValue("Q♣"), 10); +assertEquals(getCardValue("K♠"), 10); +assertEquals(getCardValue("A♥"), 11); +assertEquals(getCardValue("10♦"), 10); + +// Handling invalid cards +function assertErrors(func, errorMessage) { try { - console.log(`Card: ${card}`); - const actualOutput = getCardValue(card); + func(); + console.error("Error was not thrown for invalid card 😢"); + } catch (error) { console.assert( - actualOutput === targetOutput, - `Expected ${actualOutput} to equal ${targetOutput}` + error.message.includes(errorMessage), + `Expected error: ${errorMessage}, got: ${error.message}` ); - console.error("Error was not thrown for invalid card 😢"); - } catch (e) { console.log("Error thrown for invalid card 🎉"); } - console.log("-".repeat(45)); } -// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. -assertEquals("9♠", 9); -assertEquals("A", 11); -assertEquals("Q", 10); -assertEquals("5", 5); -assertEquals("A♣", 11); -assertEquals("Q♣", 11); -assertEquals("A♦", 10); +function testInvalidCards() { + const invalidCardCases = [ + ["A", "Invalid card suit"], + ["11♠", "Invalid card rank"], + ["N♠", "Invalid card rank"], + ["7K", "Invalid card suit"], + ["", "Invalid card"], + ]; + + invalidCardCases.forEach(([card, message]) => { + console.log("-".repeat(50)); + console.log(`Card: ${card}, Message: ${message}`); + assertErrors(() => getCardValue(card), message); + }); +} + +testInvalidCards(); 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..22739c7828 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,24 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +test(`Should return 10 when given an a face card of J, Q or K`, () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♠")).toEqual(10); + expect(getCardValue("K♠")).toEqual(10); +}); + +test(`Should return number when given an a face card (>= 2 && < 10)`, () => { + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("6♠")).toEqual(6); + expect(getCardValue("9♠")).toEqual(9); +}); + +test(`Should return an error for an invalid card`, () => { + expect(getCardValue("2")).toThrowError(); + expect(getCardValue("Q")).toThrowError(); + expect(getCardValue("5")).toThrowError(); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) @@ -17,4 +35,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 - From fd090c571d2d08d60b5da4da2d70126ff319b222 Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Fri, 26 Jun 2026 11:25:06 +0100 Subject: [PATCH 13/14] Write jest tests for 1-implement-and-rewrite-test/rewrite-test-with-jest/3-get-card-value.test.js --- .../3-get-card-value.test.js | 15 +++++++++++---- package.json | 2 +- 2 files changed, 12 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 22739c7828..8f9adab101 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 @@ -21,10 +21,17 @@ test(`Should return number when given an a face card (>= 2 && < 10)`, () => { expect(getCardValue("9♠")).toEqual(9); }); -test(`Should return an error for an invalid card`, () => { - expect(getCardValue("2")).toThrowError(); - expect(getCardValue("Q")).toThrowError(); - expect(getCardValue("5")).toThrowError(); +// Invalid cards +test(`Should return "Invalid card suit" when suit is invalid`, () => { + expect(() => getCardValue("A")).toThrowError(); +}); + +test(`Should return "Invalid card rank" when rank is invalid`, () => { + expect(() => getCardValue("1♠")).toThrowError(); +}); + +test(`Should return "Invalid card" when rank is an empty card`, () => { + expect(() => getCardValue("")).toThrowError(); }); // Suggestion: Group the remaining test data into these categories: diff --git a/package.json b/package.json index 5ebcdf7334..b663c628f2 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ "author": "Code Your Future", "license": "ISC", "devDependencies": { - "jest": "^30.4.2" + "jest": "^29.7.0" } } From 2109d2c97d516580e66e7b7c9d51c9d06c6ad1ad Mon Sep 17 00:00:00 2001 From: Martin Mwaka Date: Fri, 26 Jun 2026 11:58:01 +0100 Subject: [PATCH 14/14] Delete package.json --- 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 b663c628f2..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": "^29.7.0" - } -}