From f0ca3d73284ed41d885228e43e48c1b5a8e2e9fa Mon Sep 17 00:00:00 2001 From: bodoszidi Date: Thu, 16 Jul 2026 19:30:03 +0100 Subject: [PATCH 01/11] Implemented the function and tested --- .../implement/1-get-angle-type.js | 40 ++++++++++++++++++- 1 file changed, 39 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..d3273c6350 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) { + return "Acute angle"; + } else if (angle === 90) { + return "Right angle"; + } else if (angle > 90 && angle < 180) { + return "Obtuse angle"; + } else if (angle === 180) { + return "Straight angle"; + } else if (angle > 180 && angle < 360) { + return "Reflex angle"; + } else { + return "Invalid angle"; + } } // The line below allows us to load the getAngleType function into tests in other files. @@ -34,4 +46,30 @@ 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(66); +const obtuse = getAngleType(109); +const straight = getAngleType(180); +const reflex = getAngleType(222); +const invalid = getAngleType(366); +const boundary = getAngleType(0); +const invalidBoundary = getAngleType(360) +const acuteBoundary = getAngleType(1) +const acuteSecondBoundary = getAngleType(89) +const obtuseBoundary = getAngleType(91) +const reflexBoundary = getAngleType(181) + + + assertEquals(right, "Right angle"); +assertEquals(acute, "Acute angle"); +assertEquals(obtuse, "Obtuse angle"); +assertEquals(straight, "Straight angle"); +assertEquals(reflex, "Reflex angle") +assertEquals(invalid, "Invalid angle") +assertEquals(invalidBoundary, "Invalid angle") +assertEquals(acuteBoundary, "Acute angle") +assertEquals(acuteSecondBoundary, "Acute angle") +assertEquals(obtuseBoundary, "Obtuse angle") +assertEquals(reflexBoundary, "Reflex angle") + + From 5ad372da129b22c63eca9331b5603f770558b513 Mon Sep 17 00:00:00 2001 From: bodoszidi Date: Thu, 16 Jul 2026 19:31:05 +0100 Subject: [PATCH 02/11] added test cases --- .../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..b26253f729 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 = 90)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(90)).toEqual("Right angle"); +}); // Case 3: Obtuse angles +test(`should return "Obtuse angle" when (angle < 180, angle > 90)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); + expect(getAngleType(99)).toEqual("Obtuse angle"); +}); // Case 4: Straight angle +test(`should return "Straight angle" when (angle = 180)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(180)).toEqual("Straight angle"); +}); // Case 5: Reflex angles +test(`should return "Reflex angle" when (angle < 360, angle > 180)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(189)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); + expect(getAngleType(199)).toEqual("Reflex angle"); +}); // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle > 361, angle < 0)`, () => { + // Test various acute angles, including boundary cases + expect(getAngleType(505)).toEqual("Invalid angle"); + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(699)).toEqual("Invalid angle"); +}); \ No newline at end of file From 5c0d472e2db818153ba3451e6cf0fcbcb6638d39 Mon Sep 17 00:00:00 2001 From: bodoszidi Date: Thu, 16 Jul 2026 19:31:58 +0100 Subject: [PATCH 03/11] implemented function and tested --- .../implement/2-is-proper-fraction.js | 13 ++++++++++++- 1 file changed, 12 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 970cb9b641..bc994aa83a 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,11 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (numerator <= denominator && numerator > 0) { + return true; + } else { + return false; + } } // The line below allows us to load the isProperFraction function into tests in other files. @@ -31,3 +35,10 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(0, 4), false); +assertEquals(isProperFraction(5, 5), true); +assertEquals(isProperFraction(-8, 2), false); +assertEquals(isProperFraction(4, 0), false); +assertEquals(isProperFraction(0, 0), false); +assertEquals(isProperFraction(-2, -2), false) + From b28e30e9177be080de28d7403c2a823a15dc1fc8 Mon Sep 17 00:00:00 2001 From: bodoszidi Date: Thu, 16 Jul 2026 19:32:46 +0100 Subject: [PATCH 04/11] added jest test cases --- .../2-is-proper-fraction.test.js | 14 ++++++++++++++ 1 file changed, 14 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..456f5d79ae 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,17 @@ 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 true when denominator is smaller or equal to the numerator`,() =>{ + expect(isProperFraction(2, 4)).toEqual(true); + expect(isProperFraction(3, 3)).toEqual(true); + expect(isProperFraction(5, 10)).toEqual(true); + expect(isProperFraction(2, 2)).toEqual(true); +}); + +test(`should return false when denominator is bigger than the numerator`, () => { + expect(isProperFraction(5, -2)).toEqual(false); + expect(isProperFraction(-1, 0)).toEqual(false); + expect(isProperFraction(12, 4)).toEqual(false); + +}); + \ No newline at end of file From 241ef30aff1ada9d2d098672419d6cbcb6a6b93a Mon Sep 17 00:00:00 2001 From: bodoszidi Date: Thu, 16 Jul 2026 19:33:30 +0100 Subject: [PATCH 05/11] implemented function and tested --- .../implement/3-get-card-value.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 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 ff5c532e1d..7d38831bb8 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,7 +22,16 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + let removeSuit = card.slice(0, -1); + if (removeSuit === "A") { + return 11; + } else if (removeSuit === "J" || removeSuit === "Q" ||removeSuit === "K") { + return 10; + } else if (removeSuit > 1 && removeSuit < 11) { + return Number(removeSuit); + } else { + throw new Error("Error") + } } // The line below allows us to load the getCardValue function into tests in other files. @@ -40,11 +49,15 @@ 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("J♦"), 10); +assertEquals(getCardValue("7♥"), 7); +assertEquals(getCardValue("A♥"), 11); +assertEquals(getCardValue("8♥"), 8); // 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) { @@ -52,3 +65,11 @@ try { } // What other invalid card cases can you think of? +try { + getCardValue("15♥"); + // 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 🎉"); +} + From f0b6faa7f183876796752b895fd1bee6c92f798f Mon Sep 17 00:00:00 2001 From: bodoszidi Date: Thu, 16 Jul 2026 19:34:44 +0100 Subject: [PATCH 06/11] added jest test cases --- .../3-get-card-value.test.js | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 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 cf7f9dae2e..653bc4a194 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,29 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +test(`Should return 10 when given a Joker card`, () => { + expect(getCardValue("J♥")).toEqual(10); +}); + +test(`Should return 2 when given the 2 card`, () => { + expect(getCardValue("2♠")).toEqual(2); +}); + +test(`Should return 10 when given a King card`, () => { + expect(getCardValue("K♠")).toEqual(10); +}); + +test(`Should return 5 when given the 5 card`, () => { + expect(getCardValue("5♠")).toEqual(5); +}); + +test(`Should return 8 when gine the 8 card`, () => { + expect(getCardValue("8♠")).toEqual(8); +}); + +test(`Should return 10 when given the Queen card`, () => { + expect(getCardValue("Q♠")).toEqual(10); +}); // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) @@ -16,5 +39,9 @@ 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 - +// https://jestjs.io/docs/exåpect#tothrowerror +test(`Should not return any card should throw an error message`, () => { + expect(() => { + getCardValue("QQ♥"); + }).toThrow(); +}); From 10d37a878861bbb29acb9101265df7a757e20444 Mon Sep 17 00:00:00 2001 From: Szidonia Bodo Date: Fri, 24 Jul 2026 10:47:52 +0100 Subject: [PATCH 07/11] removed unnecessary comments Removed redundant comments from test cases for clarity. --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 8 +------- 1 file changed, 1 insertion(+), 7 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 b26253f729..2f78e56b57 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 @@ -7,7 +7,6 @@ const getAngleType = require("../implement/1-get-angle-type"); // Case 1: Acute angles test(`should return "Acute angle" when (0 < angle < 90)`, () => { - // Test various acute angles, including boundary cases expect(getAngleType(1)).toEqual("Acute angle"); expect(getAngleType(45)).toEqual("Acute angle"); expect(getAngleType(89)).toEqual("Acute angle"); @@ -15,32 +14,27 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { // Case 2: Right angle test(`should return "Right angle" when (angle = 90)`, () => { - // Test various acute angles, including boundary cases expect(getAngleType(90)).toEqual("Right angle"); }); // Case 3: Obtuse angles test(`should return "Obtuse angle" when (angle < 180, angle > 90)`, () => { - // Test various acute angles, including boundary cases expect(getAngleType(91)).toEqual("Obtuse angle"); expect(getAngleType(179)).toEqual("Obtuse angle"); expect(getAngleType(99)).toEqual("Obtuse angle"); }); // Case 4: Straight angle test(`should return "Straight angle" when (angle = 180)`, () => { - // Test various acute angles, including boundary cases expect(getAngleType(180)).toEqual("Straight angle"); }); // Case 5: Reflex angles test(`should return "Reflex angle" when (angle < 360, angle > 180)`, () => { - // Test various acute angles, including boundary cases expect(getAngleType(189)).toEqual("Reflex angle"); expect(getAngleType(359)).toEqual("Reflex angle"); expect(getAngleType(199)).toEqual("Reflex angle"); }); // Case 6: Invalid angles test(`should return "Invalid angle" when (angle > 361, angle < 0)`, () => { - // Test various acute angles, including boundary cases expect(getAngleType(505)).toEqual("Invalid angle"); expect(getAngleType(0)).toEqual("Invalid angle"); expect(getAngleType(699)).toEqual("Invalid angle"); -}); \ No newline at end of file +}); From 1230568d2824d3047a312eba4ddcab6d51531d2f Mon Sep 17 00:00:00 2001 From: Szidonia Bodo Date: Fri, 24 Jul 2026 11:09:39 +0100 Subject: [PATCH 08/11] updated the variable let to const inside the function and added additional tests Refactor variable declaration to use const for removeSuit and add test cases for Queen and King. --- .../implement/3-get-card-value.js | 4 +++- 1 file changed, 3 insertions(+), 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 7d38831bb8..e3602df0f3 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,7 +22,7 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - let removeSuit = card.slice(0, -1); + const removeSuit = card.slice(0, -1); if (removeSuit === "A") { return 11; } else if (removeSuit === "J" || removeSuit === "Q" ||removeSuit === "K") { @@ -54,6 +54,8 @@ assertEquals(getCardValue("J♦"), 10); assertEquals(getCardValue("7♥"), 7); assertEquals(getCardValue("A♥"), 11); assertEquals(getCardValue("8♥"), 8); +assertEquals(getCardValue("Q♠"), 10); +assertEquals(getCardValue("K♦"), 10); // Handling invalid cards try { From 26a0fed741fcc45ef9cef3ae39e9dd9e5ed3b1d8 Mon Sep 17 00:00:00 2001 From: Szidonia Bodo Date: Fri, 24 Jul 2026 11:10:34 +0100 Subject: [PATCH 09/11] Simplify isProperFraction function return statement --- .../implement/2-is-proper-fraction.js | 6 +----- 1 file changed, 1 insertion(+), 5 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 bc994aa83a..b707b27b5d 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,11 +11,7 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - if (numerator <= denominator && numerator > 0) { - return true; - } else { - return false; - } + return numerator <= denominator && numerator > 0 } // The line below allows us to load the isProperFraction function into tests in other files. From 9c84e3daeab27a77cd428a1353727f1542a1fa31 Mon Sep 17 00:00:00 2001 From: Szidonia Bodo Date: Fri, 24 Jul 2026 11:16:14 +0100 Subject: [PATCH 10/11] Add test to handle negative numbers Added a test case to check for proper fraction with positive numbers. --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 8 +++++--- 1 file changed, 5 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 456f5d79ae..6acd2b7946 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,9 +16,11 @@ test(`should return true when denominator is smaller or equal to the numerator`, }); test(`should return false when denominator is bigger than the numerator`, () => { + expect(isProperFraction(12, 4)).toEqual(false); +}); + +test("should return false when the numerator or denominator is not a positive number", () => { expect(isProperFraction(5, -2)).toEqual(false); expect(isProperFraction(-1, 0)).toEqual(false); - expect(isProperFraction(12, 4)).toEqual(false); - }); - \ No newline at end of file + From cb7b6ef21e44e2260ba4353c620fffa8c715c0c4 Mon Sep 17 00:00:00 2001 From: Szidonia Bodo Date: Fri, 24 Jul 2026 11:59:08 +0100 Subject: [PATCH 11/11] Grouped tests cases --- .../3-get-card-value.test.js | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 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 653bc4a194..2eb6cd39c7 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,29 +9,21 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); -test(`Should return 10 when given a Joker card`, () => { - expect(getCardValue("J♥")).toEqual(10); -}); - -test(`Should return 2 when given the 2 card`, () => { - expect(getCardValue("2♠")).toEqual(2); -}); +// Case 2: -test(`Should return 10 when given a King card`, () => { +test(`should return 10 for face cards"`, () => { + expect(getCardValue("J♥")).toEqual(10); expect(getCardValue("K♠")).toEqual(10); + expect(getCardValue("Q♣")).toEqual(10); }); -test(`Should return 5 when given the 5 card`, () => { +//Case 3: +test(`should return the numeric value of numbered cards`, () => { + expect(getCardValue("2♠")).toEqual(2); expect(getCardValue("5♠")).toEqual(5); -}); - -test(`Should return 8 when gine the 8 card`, () => { expect(getCardValue("8♠")).toEqual(8); }); -test(`Should return 10 when given the Queen card`, () => { - expect(getCardValue("Q♠")).toEqual(10); -}); // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K)