From b150432bd970e7ae29d55cdea6a24b9e27496f65 Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Sat, 21 Feb 2026 15:57:06 +0000 Subject: [PATCH 1/7] Implement getAngleType function and added tests for all angle types --- .../implement/1-get-angle-type.js | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e..e7e259cc5 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,9 +15,29 @@ // 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"; + } } +console.assert(getAngleType(45) === "Acute angle"); +console.assert(getAngleType(90) === "Right angle"); +console.assert(getAngleType(120) === "Obtuse angle"); +console.assert(getAngleType(180) === "Straight angle"); +console.assert(getAngleType(270) === "Reflex angle"); +console.assert(getAngleType(0) === "Invalid angle"); +console.assert(getAngleType(360) === "Invalid angle"); + // 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; @@ -35,3 +55,27 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + +// Example: Identify Acute Angles +const acute = getAngleType(45); +assertEquals(acute, "Acute angle"); + +// Example: Identify Obtuse Angles +const obtuse = getAngleType(120); +assertEquals(obtuse, "Obtuse angle"); + +// Example: Identify Straight Angles +const straight = getAngleType(180); +assertEquals(straight, "Straight angle"); + +// Example: Identify Reflex Angles +const reflex = getAngleType(270); +assertEquals(reflex, "Reflex angle"); + +// Example: Identify Invalid Angles +const invalid1 = getAngleType(0); +assertEquals(invalid1, "Invalid angle"); + +// Example: Identify Invalid Angles +const invalid2 = getAngleType(360); +assertEquals(invalid2, "Invalid angle"); From bec514f50ae0c92c008850f77949e32efe1babe4 Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Mon, 23 Feb 2026 18:28:52 +0000 Subject: [PATCH 2/7] Implement isProperFraction function and added tests for various fraction cases --- .../implement/2-is-proper-fraction.js | 31 +++++++++++++++++++ 1 file changed, 31 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 970cb9b64..6fc43c311 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,13 @@ function isProperFraction(numerator, denominator) { // TODO: Implement this function + if (denominator <= 0) { + return false; + } + if (numerator < denominator && numerator >= 0) { + return true; + } + return false; } // The line below allows us to load the isProperFraction function into tests in other files. @@ -31,3 +38,27 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); + +// Example: 3/5 is a proper fraction +assertEquals(properFraction(3 / 5), true); + +// Example: 1/100 is a positive fraction +assertEquals(smallFraction(1, 100), true); + +// Example: 0/4 is a proper fraction with zero numerator +assertEquals(zeroNumerator(0, 4), true); + +// Example: 7/7 is an improper fraction, +assertEquals(equalFraction(7, 7), false); + +// Example: 8/3 is an improper fraction, +assertEquals(numeratorLarger(8, 3), false); + +// Example: 5/0 is an invalid fraction +assertEquals(zeroDenominator(5, 0), false); + +// Example: 2/-6 is an invalid fraction +assertEquals(negativeDenominator(2, -6), false); + +// Example: -1/4 is an invalid fraction +assertEquals(negativeNumerator(-1, 4), false); From 72a8a7d4f38ddee31633171966812027c9b45dc3 Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Mon, 23 Feb 2026 19:20:43 +0000 Subject: [PATCH 3/7] Implement getCardValue function and added tests for valid and invalid card cases --- .../implement/2-is-proper-fraction.js | 24 +++++----- .../implement/3-get-card-value.js | 44 +++++++++++++++++++ 2 files changed, 56 insertions(+), 12 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 6fc43c311..77598e987 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 @@ -40,25 +40,25 @@ function assertEquals(actualOutput, targetOutput) { assertEquals(isProperFraction(1, 2), true); // Example: 3/5 is a proper fraction -assertEquals(properFraction(3 / 5), true); +assertEquals(isProperFraction(3, 5), true); -// Example: 1/100 is a positive fraction -assertEquals(smallFraction(1, 100), true); +// Example: 1/100 is a proper fraction +assertEquals(isProperFraction(1, 100), true); -// Example: 0/4 is a proper fraction with zero numerator -assertEquals(zeroNumerator(0, 4), true); +// Example: 5/2 is not a proper fraction +assertEquals(isProperFraction(5, 2), false); -// Example: 7/7 is an improper fraction, -assertEquals(equalFraction(7, 7), false); +// Example: 7/7 is an improper fraction +assertEquals(isProperFraction(7, 7), false); -// Example: 8/3 is an improper fraction, -assertEquals(numeratorLarger(8, 3), false); +// Example: 8/3 is an improper fraction +assertEquals(isProperFraction(8, 3), false); // Example: 5/0 is an invalid fraction -assertEquals(zeroDenominator(5, 0), false); +assertEquals(isProperFraction(5, 0), false); // Example: 2/-6 is an invalid fraction -assertEquals(negativeDenominator(2, -6), false); +assertEquals(isProperFraction(2, -6), false); // Example: -1/4 is an invalid fraction -assertEquals(negativeNumerator(-1, 4), false); +assertEquals(isProperFraction(-1, 4), 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 c7559e787..540d3b18a 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 + if (!["♠", "♣", "♦", "♥"].includes(card.slice(-1))) + throw new Error("Invalid card rank."); + const rank = card.slice(0, card.length - 1); + if (rank === "A") return 11; + if (["10", "J", "Q", "K"].includes(rank)) return 10; + if (["2", "3", "4", "5", "6", "7", "8", "9"].includes(rank)) + return Number(rank); + throw new Error("Invalid card rank."); } // The line below allows us to load the getCardValue function into tests in other files. @@ -41,6 +49,12 @@ function assertEquals(actualOutput, targetOutput) { // Examples: assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("6♥"), 6); + +assertEquals(getCardValue("J♣"), 10); + +assertEquals(getCardValue("A♦"), 11); + // Handling invalid cards try { getCardValue("invalid"); @@ -50,3 +64,33 @@ try { } catch (e) {} // What other invalid card cases can you think of? + +try { + getCardValue("9K"); + + console.log("Error was not thrown for invalid card"); +} catch (error) {} + +try { + getCardValue(""); + + console.log("Error was not thrown for invalid card"); +} catch (error) {} + +try { + getCardValue("ABC"); + + console.log("Error was not thrown for invalid card"); +} catch (error) {} + +try { + getCardValue("A"); + + console.log("Error was not thrown for invalid card"); +} catch (error) {} + +try { + getCardValue("JK"); + + console.log("Error was not thrown for invalid card"); +} catch (error) {} From 5fa76958349ebe4536fd83959893f323552df030 Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Mon, 23 Feb 2026 20:00:34 +0000 Subject: [PATCH 4/7] Add tests for angle types including right, obtuse, straight, reflex, and invalid angles --- .../1-get-angle-type.test.js | 25 +++++++++++++++++++ 1 file changed, 25 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..e8e6c2b37 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,32 @@ 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 identify obtuse angle (90° < angle < 180°)", () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(130)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}); + // Case 4: Straight angle +test("should identify straight angle (angle = 180°)", () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); + // Case 5: Reflex angles +test("should identify reflex angle (180° < angle < 360)", () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(280)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); + // Case 6: Invalid angles +test("should identify invalid angle (angle <= 0 or angle >= 360)", () => { + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); From 7e4cb27e9bb533c8fafdf5087fc5b32dc308d29d Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Mon, 23 Feb 2026 20:50:45 +0000 Subject: [PATCH 5/7] Added tests for isProperFraction covering various cases including zero, negative, decimal, and large numbers --- .../2-is-proper-fraction.test.js | 62 +++++++++++++++++++ 1 file changed, 62 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 7f087b2ba..b0146664d 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,65 @@ 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 numerator is zero and denominator is non-zero", () => { + expect(isProperFraction(0, 5)).toEqual(true); +}); + +test("should return false when both numerator and denominator are zero", () => { + expect(isProperFraction(0, 0)).toEqual(false); +}); + +// Special case: Identify proper Fractions: +test("should return true for proper fraction", () => { + expect(isProperFraction(2, 3)).toEqual(true); +}); + +// Special case: Identify Negative Fractions: +test("should return true for proper negative fraction", () => { + expect(isProperFraction(-3, 6)).toEqual(true); +}); + +test("should return false for improper negative fraction", () => { + expect(isProperFraction(-5, 2)).toEqual(false); +}); + +test("should return true for proper fraction with negative denominator", () => { + expect(isProperFraction(2, -5)).toEqual(true); +}); + +test("should return false for improper fraction with negative denominator", () => { + expect(isProperFraction(7, -3)).toEqual(false); +}); + +// Special case: Identify Equal Numerator and Denominator: +test("should return false for improper fraction (numerator === denominator)", () => { + expect(isProperFraction(3, 3)).toEqual(false); +}); + +// Special case: Identify both Numerator and Denominator as negative +test("should return true when both numerator and denominator are negative and proper", () => { + expect(isProperFraction(-2, -5)).toEqual(true); +}); + +test("should return false when both numerator and denominator are negative and improper", () => { + expect(isProperFraction(-6, -3)).toEqual(false); +}); + +// Special case: Identify both Numerator and Denominator as decimal +test("should return true for proper decimal fractions", () => { + expect(isProperFraction(1.5, 2.5)).toEqual(true); +}); + +test("should return false for improper decimal fractions", () => { + expect(isProperFraction(2.5, 1.5)).toEqual(false); +}); + +// Special case: Identify both Numerator and Denominator as large numbers +test("should return true for large proper fractions", () => { + expect(isProperFraction(100, 1000)).toEqual(true); +}); + +test("should return false for large improper fractions", () => { + expect(isProperFraction(1000, 100)).toEqual(false); +}); From 56c990b01a66a819739a27241d2acfb4c29aab84 Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Mon, 23 Feb 2026 21:09:46 +0000 Subject: [PATCH 6/7] Added tests for getCardValue function covering Aces, Number cards, Face cards, and Invalid cards --- .../3-get-card-value.test.js | 69 ++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index cf7f9dae2..44102ed74 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -7,6 +7,74 @@ const getCardValue = require("../implement/3-get-card-value"); // Case 1: Ace (A) test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); + expect(getCardValue("A♣")).toEqual(11); + expect(getCardValue("A♦")).toEqual(11); + expect(getCardValue("A♥")).toEqual(11); +}); + +// Case 2: Handle Number Cards (2-10): +test("should return the appropriate number from 2 to 10", () => { + expect(getCardValue("2♥")).toEqual(2); + expect(getCardValue("3♥")).toEqual(3); + expect(getCardValue("4♥")).toEqual(4); + expect(getCardValue("5♥")).toEqual(5); + expect(getCardValue("6♥")).toEqual(6); + expect(getCardValue("7♥")).toEqual(7); + expect(getCardValue("8♥")).toEqual(8); + expect(getCardValue("9♥")).toEqual(9); + expect(getCardValue("10♥")).toEqual(10); + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("3♠")).toEqual(3); + expect(getCardValue("4♠")).toEqual(4); + expect(getCardValue("5♠")).toEqual(5); + expect(getCardValue("6♠")).toEqual(6); + expect(getCardValue("7♠")).toEqual(7); + expect(getCardValue("8♠")).toEqual(8); + expect(getCardValue("9♠")).toEqual(9); + expect(getCardValue("10♠")).toEqual(10); + expect(getCardValue("2♦")).toEqual(2); + expect(getCardValue("3♦")).toEqual(3); + expect(getCardValue("4♦")).toEqual(4); + expect(getCardValue("5♦")).toEqual(5); + expect(getCardValue("6♦")).toEqual(6); + expect(getCardValue("7♦")).toEqual(7); + expect(getCardValue("8♦")).toEqual(8); + expect(getCardValue("9♦")).toEqual(9); + expect(getCardValue("10♦")).toEqual(10); + expect(getCardValue("2♣")).toEqual(2); + expect(getCardValue("3♣")).toEqual(3); + expect(getCardValue("4♣")).toEqual(4); + expect(getCardValue("5♣")).toEqual(5); + expect(getCardValue("6♣")).toEqual(6); + expect(getCardValue("7♣")).toEqual(7); + expect(getCardValue("8♣")).toEqual(8); + expect(getCardValue("9♣")).toEqual(9); + expect(getCardValue("10♣")).toEqual(10); +}); + +// Case 3: Handle Face Cards (J, Q, K): +test("should return 10 for face cards", () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♠")).toEqual(10); + expect(getCardValue("K♠")).toEqual(10); + expect(getCardValue("J♦")).toEqual(10); + expect(getCardValue("Q♦")).toEqual(10); + expect(getCardValue("K♦")).toEqual(10); + expect(getCardValue("J♣")).toEqual(10); + expect(getCardValue("Q♣")).toEqual(10); + expect(getCardValue("K♣")).toEqual(10); + expect(getCardValue("J♥")).toEqual(10); + expect(getCardValue("Q♥")).toEqual(10); + expect(getCardValue("K♥")).toEqual(10); +}); + +// Case 4: Handle Invalid Cards: +test("Should return 'Invalid card rank.' for invalid cards", () => { + expect(() => getCardValue("KJ")).toThrow("Invalid card rank."); + expect(() => getCardValue("AK")).toThrow("Invalid card rank."); + expect(() => getCardValue(" ")).toThrow("Invalid card rank."); + expect(() => getCardValue("S♠")).toThrow("Invalid card rank."); + expect(() => getCardValue("J♠♠")).toThrow("Invalid card rank."); }); // Suggestion: Group the remaining test data into these categories: @@ -17,4 +85,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 ad8efb8af6707896d2f087079476971c9c344264 Mon Sep 17 00:00:00 2001 From: Asha Ahmed Date: Mon, 23 Feb 2026 21:34:15 +0000 Subject: [PATCH 7/7] renamed brach --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 2 +- 1 file changed, 1 insertion(+), 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 b0146664d..4c157706a 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,7 @@ 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); });