From bfd3913d82f7f94bd4fab6297f5a98bc6ddab41a Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Fri, 9 Oct 2026 16:42:06 +0100 Subject: [PATCH 01/32] 1-get-angle-type Comment out pseudo code Give-when-then --- .../implement/1-get-angle-type.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 8a6fba050..757fdc312 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -19,3 +19,15 @@ export function getAngleType(angle) { // TODO: Implement this function } + +//Cases showcases +//First define type: Num (whole number) +//Then range: 0 - 360 +//Cases: +//1. 0-89 : Actute angle +//2. 90 : Right angle +//3. 91-179: Obtuse angle +//4. 180: Straight angle +//5. 181-359 : Reflex angle +//6. 360 and beyond Invalid angle +//Key word to use : If? From 1f731d2167ec5487550405f43d7e5d77cbee4842 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Fri, 9 Oct 2026 16:43:13 +0100 Subject: [PATCH 02/32] 2-is-proper-fraction Add comments to clarify the isProperFraction function's purpose and expected behavior --- .../implement/2-is-proper-fraction.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index f983800f0..cfba79386 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -16,3 +16,9 @@ export function isProperFraction(numerator, denominator) { // TODO: Implement this function } + +//Cases show cases +//Proper function ; improper function +//Input type: Num +//Process : number to logic test +//Output type: boolean From 4ef98cd5ef226d5b23cc84e7dfa38f69fe8b6b44 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Fri, 9 Oct 2026 16:44:17 +0100 Subject: [PATCH 03/32] 3-get-card-value.js Add comments to clarify the isProperFraction function's purpose and expected behavior --- implement-and-rewrite-tests/implement/3-get-card-value.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 9614ab1ee..9c107674f 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -26,3 +26,8 @@ export function getCardValue(card) { // TODO: Implement this function } + +//Case showcases +//Input: (Rank) "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and (Suit), also invalid input +//Process Turn input into Num : "A" to 11 ; ("J", "Q", "K") to 10 +//Output : a valid Num , or invalid throw error From c44e20a99fb761bc311bdfcce1b063a163b69f65 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Fri, 9 Oct 2026 22:44:33 +0100 Subject: [PATCH 04/32] Implement getAngleType function to determine angle types based on input value --- .../implement/1-get-angle-type.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 757fdc312..b62a8ce34 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -18,9 +18,26 @@ export function getAngleType(angle) { // TODO: Implement this function + + if (angle < 0 || angle > 360) { + return `Invalid angle`; + } + if (angle < 90) { + return `Acute angle`; + } + if (angle == 90) { + return `Right angle`; + } + if (angle === 180) { + return `Straight angle`; + } + if (angle < 180) { + return `Obtuse angle`; + } + return ` Reflex angle`; } -//Cases showcases +//Pseudo codes //First define type: Num (whole number) //Then range: 0 - 360 //Cases: From 06782aac8b2d2132a67234194085ad617b2158f3 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Fri, 9 Oct 2026 23:40:38 +0100 Subject: [PATCH 05/32] 2-is-proper-fraction.js implement the function isProperFraction, added edge cases: not a number, not a finite number, 0 as denominator --- .../implement/2-is-proper-fraction.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index cfba79386..b1a61cf85 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -15,10 +15,28 @@ export function isProperFraction(numerator, denominator) { // TODO: Implement this function + if (typeof numerator !== "number" || typeof denominator !== "number") { + throw new TypeError("Both arguments must be numbers"); + } + if (!Number.isFinite(numerator) || !Number.isFinite(denominator)) { + throw new TypeError("Both arguments must be numbers"); + } + + if (denominator === 0) { + return `Not a valid fraction`; + } + + if (Math.abs(numerator) < Math.abs(denominator)) { + return true; + } + + return false; } //Cases show cases //Proper function ; improper function //Input type: Num //Process : number to logic test -//Output type: boolean +//Output type: boolean or error +//Edge case : negative number +//Edge case: decimal From b405180d54791ce7e9fb816ef75cf9500a545846 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 10 Oct 2026 17:32:27 +0100 Subject: [PATCH 06/32] 1-get-angle-type.js fixed typo for test --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index b62a8ce34..a43f5fb6a 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -34,7 +34,7 @@ export function getAngleType(angle) { if (angle < 180) { return `Obtuse angle`; } - return ` Reflex angle`; + return `Reflex angle`; } //Pseudo codes From 327decdae6ae9838981d357e9a8df0d84e7bd1c7 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 10 Oct 2026 17:33:50 +0100 Subject: [PATCH 07/32] 1-get-angle-type.test.js write 9 additional test cases. Ran tests. --- .../1-get-angle-type.test.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index cf50f6cad..4d01ab105 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -10,3 +10,58 @@ test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); + +test("Classifies obtuse angles", () => { + const right = getAngleType(91); + assert.equal(right, "Obtuse angle"); +}); + +test("Classifies obtuse angles", () => { + const right = getAngleType(179); + assert.equal(right, "Obtuse angle"); +}); + +test("Classifies Straight angles", () => { + const right = getAngleType(180); + assert.equal(right, "Straight angle"); +}); + +test("Classifies Reflex angles", () => { + const right = getAngleType(181); + assert.equal(right, "Reflex angle"); +}); + +test("Classifies Reflex angles", () => { + const right = getAngleType(359); + assert.equal(right, "Reflex angle"); +}); + +test("Classifies Reflex angles", () => { + const right = getAngleType(360); + assert.equal(right, "Reflex angle"); +}); + +test("Classifies Invalid angles", () => { + const right = getAngleType(361); + assert.equal(right, "Invalid angle"); +}); + +test("Classifies Invalid angles", () => { + const right = getAngleType(361); + assert.equal(right, "Invalid angle"); +}); + +test("Classifies Invalid angles", () => { + const right = getAngleType(-1); + assert.equal(right, "Invalid angle"); +}); + + + + +// - "Acute angle" for angles greater than 0° and less than 90° +// - "Right angle" for exactly 90° +// - "Obtuse angle" for angles greater than 90° and less than 180° +// - "Straight angle" for exactly 180° +// - "Reflex angle" for angles greater than 180° and less than 360° +// - "Invalid angle" for angles outside the valid range. From 88a6000c0ea19341fa3926e6781cc273cf37fb2b Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 10 Oct 2026 22:46:10 +0100 Subject: [PATCH 08/32] 3-get-card-value.js added implementation code, define string as input type of card ; define Rank and Suit composing value of card, define validRanks and valid Suits; --- .../implement/3-get-card-value.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 9c107674f..968442da6 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -25,9 +25,38 @@ export function getCardValue(card) { // TODO: Implement this function +if(typeof card !== String){ + throw new TypeError("Input not a string"); + } +const Rank = [card.Slice(0,-1)]; +const Suit = [card.Slice(-1)]; +const validRanks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; +const validSuits = [ "♠", "♥", "♦", "♣"]; + +if (!validRanks.includes(Rank)||!validSuits.includes(Suit)){ + return `Invalid input` } +if (Rank === "A") { + return 11 +} + +if (["J", "Q", "K" ].includes(Rank)){ + return 10 +} + +return Number(Rank) +} + + //Case showcases //Input: (Rank) "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and (Suit), also invalid input +//Input type: String //Process Turn input into Num : "A" to 11 ; ("J", "Q", "K") to 10 //Output : a valid Num , or invalid throw error +//const rank +//const suit +//Edge cases 0: not string +//Edge cases 1: ANy first letter which is not a Rank; +//Edge cases 2: Not a Rank plus Suit input; +//Edge cases 3: Suit mistyped ; or second character is not a suit From 401ad2ba69fce1b6727f9495e4f7e8c8a37d9fb6 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 11 Oct 2026 15:53:46 +0100 Subject: [PATCH 09/32] 2-is-proper-fraction.test wrote 8 additional test cases: equal , improper fraction, 0 numerator, 0 denominator, non-numeric numerator , non-numeric denominator, not a number (NaN), infinity denominator --- .../2-is-proper-fraction.test.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index a29084605..077eebe8f 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -10,3 +10,35 @@ test("Basic proper fraction", () => { // Example: 1/2 is a proper fraction assert.equal(isProperFraction(1, 2), true); }); + +test("Equal numerator and denominator is not a proper fraction", () => { + assert.equal(isProperFraction(2, 2), false); +}); + +test("Improper fraction is false", () => { + assert.equal(isProperFraction(3, 2), false); +}); + +test("Zero numerator with positive denominator is a proper fraction", () => { + assert.equal(isProperFraction(0, 2), true); +}); + +test("Non-numeric numerator throws TypeError", () => { + assert.throws(() => isProperFraction("1", 2), TypeError); +}); + +test("Non-numeric denominator throws TypeError", () => { + assert.throws(() => isProperFraction(1, "2"), TypeError); +}); + +test("NaN numerator throws TypeError", () => { + assert.throws(() => isProperFraction(Number.NaN, 2), TypeError); +}); + +test("Infinity denominator throws TypeError", () => { + assert.throws(() => isProperFraction(1, Number.POSITIVE_INFINITY), TypeError); +}); + +test("Denominator is 0 throws TypeError", () => { + assert.throws(() => isProperFraction(1, 0), TypeError); +}); From acfaabd5e11e78349f10c3277af3ebaaea5f4cb7 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 11 Oct 2026 15:54:39 +0100 Subject: [PATCH 10/32] 2-is-proper-fraction edited denominator=0 to correct exception for tests --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index b1a61cf85..ce10d7168 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -23,7 +23,7 @@ export function isProperFraction(numerator, denominator) { } if (denominator === 0) { - return `Not a valid fraction`; + throw new TypeError("Denominator cannot be zero"); } if (Math.abs(numerator) < Math.abs(denominator)) { From a963f0f07f870e4b1fb0cc311ae2b456611b7c77 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 11 Oct 2026 20:41:47 +0100 Subject: [PATCH 11/32] 3-getCardValue function to provide specific error messages for invalid rank and suit inputs --- .../implement/3-get-card-value.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 968442da6..f6a05bd98 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -33,10 +33,15 @@ const Suit = [card.Slice(-1)]; const validRanks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; const validSuits = [ "♠", "♥", "♦", "♣"]; -if (!validRanks.includes(Rank)||!validSuits.includes(Suit)){ - return `Invalid input` +if (!validRanks.includes(Rank)){ + return `Invalid Rank` } +if (!validSuits.includes(Suit)){ + return `Invalid Suit` +} + + if (Rank === "A") { return 11 } From 19d4b523e631173ab043fdda5db6dee4f7084276 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 11 Oct 2026 20:42:06 +0100 Subject: [PATCH 12/32] Add tests for invalid rank and suit inputs in getCardValue function --- .../3-get-card-value.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index f5092d9b1..e67b6ae3f 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -13,4 +13,24 @@ test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); +test("Invalid Rank", () => { + assert.throws(() => getCardValue("Invalid Rank"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); +}); + +test("Invalid Suit", () => { + assert.throws(() => getCardValue("Invalid Suit"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); +}); // TODO: What other invalid card cases can you think of? +//Invalid Rank or +//Invalid String +////Out of range input +//Input: (Rank) "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and (Suit), also invalid input +//Input type: String +//Process Turn input into Num : "A" to 11 ; ("J", "Q", "K") to 10 +//Output : a valid Num , or invalid throw error +//const rank +//const suit +//Edge cases 0: not string +//Edge cases 1: ANy first letter which is not a Rank; +//Edge cases 2: Not a Rank plus Suit input; +//Edge cases 3: Suit mistyped ; or second character is not a suit \ No newline at end of file From 52e4cd116f80f7002bc6fb105e8503e26c7434c1 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 12 Oct 2026 12:46:29 +0100 Subject: [PATCH 13/32] Refactor getCardValue function to improve error handling for invalid rank and suit inputs --- .../implement/3-get-card-value.js | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index f6a05bd98..255933aab 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -25,42 +25,54 @@ export function getCardValue(card) { // TODO: Implement this function -if(typeof card !== String){ - throw new TypeError("Input not a string"); + if (typeof card !== "string") { + throw new TypeError("Input not a string"); } -const Rank = [card.Slice(0,-1)]; -const Suit = [card.Slice(-1)]; -const validRanks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; -const validSuits = [ "♠", "♥", "♦", "♣"]; + const Rank = card.slice(0, -1); + const Suit = card.slice(-1); + const validRanks = [ + "A", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "J", + "Q", + "K", + ]; + const validSuits = ["♠", "♥", "♦", "♣"]; -if (!validRanks.includes(Rank)){ - return `Invalid Rank` -} - -if (!validSuits.includes(Suit)){ - return `Invalid Suit` -} + if (!validRanks.includes(Rank)) { + throw new Error("Invalid Rank"); + } + if (!validSuits.includes(Suit)) { + throw new Error("Invalid Suit"); + } -if (Rank === "A") { - return 11 -} + if (Rank === "A") { + return 11; + } -if (["J", "Q", "K" ].includes(Rank)){ - return 10 -} + if (["J", "Q", "K"].includes(Rank)) { + return 10; + } -return Number(Rank) + return Number(Rank); } - //Case showcases //Input: (Rank) "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and (Suit), also invalid input //Input type: String //Process Turn input into Num : "A" to 11 ; ("J", "Q", "K") to 10 //Output : a valid Num , or invalid throw error //const rank -//const suit +//const suit //Edge cases 0: not string //Edge cases 1: ANy first letter which is not a Rank; //Edge cases 2: Not a Rank plus Suit input; From 3064fb81ec1b28714cad0b539a23067b4a06cb38 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 12 Oct 2026 12:46:57 +0100 Subject: [PATCH 14/32] Tests for getCardValue function to improve clarity and error messaging for invalid inputs --- .../3-get-card-value.test.js | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index e67b6ae3f..34cae540f 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -9,19 +9,31 @@ test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); -test("Arbitrary non-card string", () => { - assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); -}); - test("Invalid Rank", () => { - assert.throws(() => getCardValue("Invalid Rank"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); + assert.throws( + () => getCardValue("1♥"), + /Invalid Rank/, + "Expected clear error" + ); }); test("Invalid Suit", () => { - assert.throws(() => getCardValue("Invalid Suit"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); + assert.throws( + () => getCardValue("9x"), + /Invalid Suit/, + "Expected clear error" + ); +}); + +test("Non-string input", () => { + assert.throws( + () => getCardValue(9), + /Input not a string/, + "Expected clear error" + ); }); // TODO: What other invalid card cases can you think of? -//Invalid Rank or +//Invalid Rank or //Invalid String ////Out of range input //Input: (Rank) "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and (Suit), also invalid input @@ -29,8 +41,8 @@ test("Invalid Suit", () => { //Process Turn input into Num : "A" to 11 ; ("J", "Q", "K") to 10 //Output : a valid Num , or invalid throw error //const rank -//const suit +//const suit //Edge cases 0: not string //Edge cases 1: ANy first letter which is not a Rank; -//Edge cases 2: Not a Rank plus Suit input; -//Edge cases 3: Suit mistyped ; or second character is not a suit \ No newline at end of file +//Edge cases 2: Any second character which is not a Suit +//Edge cases 3: Both Rank plus Suit input invalid; From 8edda7643469af421135e782952c1aa31ca39043 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Tue, 13 Oct 2026 10:31:22 +0100 Subject: [PATCH 15/32] test: rewrite getAngleType tests with Jest --- .../1-get-angle-type.test.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index e0ba786ab..c90e0fc74 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -12,7 +12,61 @@ 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)`, () => { + // Test various obtuse angles, including boundary cases + 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 = 180`, () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); // Case 5: Reflex angles +test(`should return "Reflex angle" when (180 < angle < 360)`, () => { + // Test various reflex angles, including boundary cases + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(225)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle < 0 or angle > 360)`, () => { + // Test various invalid angles, including boundary cases + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); + expect(getAngleType(-0.5)).toEqual("Invalid angle"); +}); + +//test("Classifies right angles", () => { +// const right = getAngleType(90); + +//test("Classifies obtuse angles", () => { +// const right = getAngleType(91); + +//test("Classifies obtuse angles", () => { +// const right = getAngleType(179); + +//test("Classifies Straight angles", () => { +// const right = getAngleType(180); + +//test("Classifies Reflex angles", () => { +// const right = getAngleType(181); + +//test("Classifies Reflex angles", () => { +// const right = getAngleType(359); + +//test("Classifies Reflex angles", () => { +// const right = getAngleType(360); + +//test("Classifies Invalid angles", () => { +// const right = getAngleType(361); + +//test("Classifies Invalid angles", () => { +// const right = getAngleType(361); + +//test("Classifies Invalid angles", () => { +// const right = getAngleType(-1); From af9a9585b3093c744ebb22aef8ac9c519d8b631b Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 13 Oct 2026 15:07:48 +0100 Subject: [PATCH 16/32] 2-is-proper-fraction jest test: expand isProperFraction tests to cover edge cases and error handling --- .../2-is-proper-fraction.test.js | 90 ++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 5d49e2d8b..8d63e53d9 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -3,6 +3,92 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; // 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('should throw error when denominator is zero', () => { + expect(() => isProperFraction(1, 0)).toThrow(Error); }); +// Case1: numerator is zero +test('should return true when numerator is zero', () => { + expect(isProperFraction(0, 2)).toEqual(true); +}); +// Case2: denominator is Infinity +test('should throw TypeError when denominator is infinity', () => { + expect(() => isProperFraction(1, Infinity)).toThrow(TypeError); +}); +// Case3: numerator is Infinity +test('should throw TypeError when numerator is Infinity', () => { + expect(() => isProperFraction(Number.POSITIVE_INFINITY, 2)).toThrow(TypeError); +}); +// Case4: denominator is not a number +test('should throw TypeError when denominator is not a number', () => { + expect(() => isProperFraction(1, "2")).toThrow(TypeError); + expect(() => isProperFraction(2, "3")).toThrow(TypeError); + expect(() => isProperFraction(3, "1")).toThrow(TypeError); +}); +// Case5: numerator is not a number +test('should throw TypeError when numerator is not a number', () => { + expect(() => isProperFraction("1", 2)).toThrow(TypeError); + expect(() => isProperFraction("2", 3)).toThrow(TypeError); + expect(() => isProperFraction("3", 2)).toThrow(TypeError); +}); +// Case6: improper fraction with positive numerator and denominator +test('should return false for improper fraction', () => { + expect(isProperFraction(3, 2)).toEqual(false); + expect(isProperFraction(5, 3)).toEqual(false); + expect(isProperFraction(10, 5)).toEqual(false); +}); +// Case7: equal numerator and denominator +test('should return false for equal numerator and denominator', () => { + expect(isProperFraction(2, 2)).toEqual(false); + expect(isProperFraction(5, 5)).toEqual(false); + expect(isProperFraction(10, 10)).toEqual(false); +}); +// Case8: equal numerator and negative denominator +test('should return false for equal numerator and negative denominator', () => { + expect(isProperFraction(2, -2)).toEqual(false); + expect(isProperFraction(5, -5)).toEqual(false); + expect(isProperFraction(10, -10)).toEqual(false); +}); +// Case9: negative improper fraction with positive denominator +test('should return false for negative improper fraction', () => { + expect(isProperFraction(-3, 2)).toEqual(false); + expect(isProperFraction(-5, 3)).toEqual(false); + expect(isProperFraction(-10, 5)).toEqual(false); +}); +// Case10: negative improper fraction with negative numerator +test('should return true for negative proper fraction', () => { + expect(isProperFraction(-1, 2)).toEqual(true); + expect(isProperFraction(-2, 3)).toEqual(true); + expect(isProperFraction(-3, 4)).toEqual(true); +}); +// Case11: proper fraction with negative denominator +test('should return true for proper fraction with negative denominator', () => { + expect(isProperFraction(1, -2)).toEqual(true); + expect(isProperFraction(2, -3)).toEqual(true); + expect(isProperFraction(3, -4)).toEqual(true); +}); +// Case12: improper fraction with negative denominator +test('should return false for improper fraction with negative denominator', () => { + expect(isProperFraction(3, -2)).toEqual(false); + expect(isProperFraction(5, -3)).toEqual(false); + expect(isProperFraction(10, -5)).toEqual(false); +}); +// Case13: proper fraction with both negative numerator and denominator +test('should return true for proper fraction with both negative numerator and denominator', () => { + expect(isProperFraction(-1, -2)).toEqual(true); + expect(isProperFraction(-2, -3)).toEqual(true); + expect(isProperFraction(-3, -4)).toEqual(true); +}); +// Case14: improper fraction with both negative numerator and denominator +test('should return false for improper fraction with both negative numerator and denominator', () => { + expect(isProperFraction(-3, -2)).toEqual(false); + expect(isProperFraction(-5, -3)).toEqual(false); + expect(isProperFraction(-10, -5)).toEqual(false); +}); + + +test('should return true for proper fraction', () => { + expect(isProperFraction(1, 2)).toEqual(true); + expect(isProperFraction(2, 3)).toEqual(true); +}); + + From 77f89cc0a20131035b35f9ebd712f120f47517ff Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 13 Oct 2026 15:34:21 +0100 Subject: [PATCH 17/32] 3-get-card-value write jest tests to cover additional edge cases and invalid inputs --- .../3-get-card-value.test.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index a6de5a82a..06c8d1531 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -7,6 +7,59 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +// Case 2: Face cards (J, Q, K) +test(`Should return 10 when given a face card`, () => { + expect(getCardValue("J♣")).toEqual(10); + expect(getCardValue("Q♦")).toEqual(10); + expect(getCardValue("K♥")).toEqual(10); +}); + +// Case 3: Number cards (2-10) +test(`Should return the correct value for number cards`, () => { + 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 4: Invalid ranks +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("11♠")).toThrow(Error); + expect(() => getCardValue("1♣")).toThrow(Error); + expect(() => getCardValue("H♠")).toThrow(Error); +}); + +// Case 5: Invalid suits +test(`Should throw an error when given an invalid suit`, () => { + expect(() => getCardValue("A♤")).toThrow(Error); + expect(() => getCardValue("10X")).toThrow(Error); + expect(() => getCardValue("KZ")).toThrow(Error); +}); + +// Case 6: Invalid input types +test(`Should throw an error when given a non-string input`, () => { + expect(() => getCardValue(10)).toThrow(Error); + expect(() => getCardValue(null)).toThrow(Error); + expect(() => getCardValue(undefined)).toThrow(Error); + expect(() => getCardValue({})).toThrow(Error); + expect(() => getCardValue([])).toThrow(Error); +}); + +// Case 7: Edge cases +test(`Should throw an error for edge cases`, () => { + expect(() => getCardValue("")).toThrow(Error); + expect(() => getCardValue("A")).toThrow(Error); + expect(() => getCardValue("♠")).toThrow(Error); + expect(() => getCardValue("A♠♣")).toThrow(Error); + expect(() => getCardValue("10♠♣")).toThrow(Error); +}); + + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 01e39871753cfa1593bbb428fe6580afa6d30c49 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 13 Oct 2026 15:38:06 +0100 Subject: [PATCH 18/32] 2-is-proper-fraction jest test: numbering cases in comment for easy count --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 8d63e53d9..ef0d731a5 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -85,7 +85,7 @@ test('should return false for improper fraction with both negative numerator and expect(isProperFraction(-10, -5)).toEqual(false); }); - +// Case15: proper fraction with positive numerator and denominator test('should return true for proper fraction', () => { expect(isProperFraction(1, 2)).toEqual(true); expect(isProperFraction(2, 3)).toEqual(true); From 45b7e1272a24af274caa6d0ec580f1eac5bb0e6c Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 27 Oct 2026 17:40:12 +0000 Subject: [PATCH 19/32] 1-get-angle-type.js: update getAngleType function for angle validation and strict equality checks --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index a43f5fb6a..15244eddc 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -17,15 +17,15 @@ // execute the code to ensure all tests pass. export function getAngleType(angle) { - // TODO: Implement this function + - if (angle < 0 || angle > 360) { + if (angle <= 0 || angle >= 360) { return `Invalid angle`; } if (angle < 90) { return `Acute angle`; } - if (angle == 90) { + if (angle === 90) { return `Right angle`; } if (angle === 180) { From 0c031bfc9afd27199ecceb2cfddea7c9775d4414 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 27 Oct 2026 17:41:11 +0000 Subject: [PATCH 20/32] 1-get-angle-type.test.js:update angle classification tests to correct invalid angle handling and add acute angle cases --- .../1-get-angle-type.test.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 4d01ab105..ec74e82ae 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -36,9 +36,9 @@ test("Classifies Reflex angles", () => { assert.equal(right, "Reflex angle"); }); -test("Classifies Reflex angles", () => { +test("Classifies Invalid angles", () => { const right = getAngleType(360); - assert.equal(right, "Reflex angle"); + assert.equal(right, "Invalid angle"); }); test("Classifies Invalid angles", () => { @@ -47,17 +47,34 @@ test("Classifies Invalid angles", () => { }); test("Classifies Invalid angles", () => { - const right = getAngleType(361); + const right = getAngleType(-1); assert.equal(right, "Invalid angle"); }); test("Classifies Invalid angles", () => { - const right = getAngleType(-1); + const right = getAngleType(0); assert.equal(right, "Invalid angle"); }); +test("Classifies Acute angles", () => { + const right = getAngleType(1); + assert.equal(right, "Acute angle"); +}); + +test("Classifies Acute angles", () => { + const right = getAngleType(89); + assert.equal(right, "Acute angle"); +}); +test("Classifies Acute angles", () => { + const right = getAngleType(45); + assert.equal(right, "Acute angle"); +}); +test("Classifies Acute angles", () => { + const right = getAngleType(0.5); + assert.equal(right, "Acute angle"); +}); // - "Acute angle" for angles greater than 0° and less than 90° // - "Right angle" for exactly 90° From 8fd112fc42321cfa0dc8b00e98e58c0c7a19bbc4 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 27 Oct 2026 17:41:58 +0000 Subject: [PATCH 21/32] 1-get-angle-type.test.js:update invalid angle jest tests to include boundary cases and improve clarity --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index c90e0fc74..e78ab51c3 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -34,8 +34,10 @@ test(`should return "Reflex angle" when (180 < angle < 360)`, () => { expect(getAngleType(359)).toEqual("Reflex angle"); }); // Case 6: Invalid angles -test(`should return "Invalid angle" when (angle < 0 or angle > 360)`, () => { +test(`should return "Invalid angle" when (angle <= 0 or angle >= 360)`, () => { // Test various invalid angles, including boundary cases + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); expect(getAngleType(-1)).toEqual("Invalid angle"); expect(getAngleType(361)).toEqual("Invalid angle"); expect(getAngleType(-0.5)).toEqual("Invalid angle"); From 5c43771176d5051f735aa78d46347021c987316d Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 27 Oct 2026 17:48:53 +0000 Subject: [PATCH 22/32] 3-get-card-value.js :update getCardValue function to validate card length and throw descriptive error for invalid input --- implement-and-rewrite-tests/implement/3-get-card-value.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 255933aab..d3b159b14 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -28,6 +28,9 @@ export function getCardValue(card) { if (typeof card !== "string") { throw new TypeError("Input not a string"); } + if (card.length < 2 || card.length > 3) { + throw new Error(`Expected a number followed by a suit, but got "${card}"`); + } const Rank = card.slice(0, -1); const Suit = card.slice(-1); const validRanks = [ From b78850cd90faeea44b0ae6d54d4460c5113a07fc Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 27 Oct 2026 17:54:46 +0000 Subject: [PATCH 23/32] add test for arbitrary non-card string in getCardValue function --- .../3-get-card-value.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 34cae540f..a6550c5e1 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -32,6 +32,14 @@ test("Non-string input", () => { "Expected clear error" ); }); + +test("Arbitrary non-card string", () => { +  assert.throws( + () => getCardValue("invalid"), + /Expected a number followed by a suit,/, + "Expected clear error" +); +}); // TODO: What other invalid card cases can you think of? //Invalid Rank or //Invalid String From db81cc020c56633b21dfcc54633cb1ea6e505a5b Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 06:57:35 +0000 Subject: [PATCH 24/32] add test cases for negative proper fractions in isProperFraction function --- .../2-is-proper-fraction.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 077eebe8f..f7b28d65c 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -42,3 +42,9 @@ test("Infinity denominator throws TypeError", () => { test("Denominator is 0 throws TypeError", () => { assert.throws(() => isProperFraction(1, 0), TypeError); }); + +test("should return true for negative proper fraction", () => { +  assert.equal(isProperFraction(-1, 2), true); +  assert.equal(isProperFraction(-2, 3), true); +  assert.equal(isProperFraction(-3, 4), true); +}); \ No newline at end of file From 96d3a8fb7184e1bb0b30b6a58412967f667b1f27 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 06:57:48 +0000 Subject: [PATCH 25/32] add tests for card classification including ace, face, and 10 cards --- .../3-get-card-value.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index a6550c5e1..31f493d3c 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -40,6 +40,20 @@ test("Arbitrary non-card string", () => { "Expected clear error" ); }); + +test("Classifies ace cards", () => { +  assert.equal(getCardValue("A♠"), 11); +}); + +test("Classifies face cards", () => { +  assert.equal(getCardValue("J♠"), 10); +  assert.equal(getCardValue("Q♠"), 10); +  assert.equal(getCardValue("K♠"), 10); +}); + +test("Classifies 10 cards", () => { +  assert.equal(getCardValue("10♠"), 10); +}); // TODO: What other invalid card cases can you think of? //Invalid Rank or //Invalid String From 38d4be7a0cd4bba93d57c42d49399f8a9cfe2597 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 07:01:48 +0000 Subject: [PATCH 26/32] remove outdated comments from angle classification tests for clarity --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index ec74e82ae..7ed626263 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -76,9 +76,3 @@ test("Classifies Acute angles", () => { assert.equal(right, "Acute angle"); }); -// - "Acute angle" for angles greater than 0° and less than 90° -// - "Right angle" for exactly 90° -// - "Obtuse angle" for angles greater than 90° and less than 180° -// - "Straight angle" for exactly 180° -// - "Reflex angle" for angles greater than 180° and less than 360° -// - "Invalid angle" for angles outside the valid range. From d3f9a5391cb598e49530ac263d9ecef4f7f886c6 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 07:03:28 +0000 Subject: [PATCH 27/32] remove outdated TODO comments from card value tests for clarity --- .../3-get-card-value.test.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 31f493d3c..55d3477b7 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -54,17 +54,3 @@ test("Classifies face cards", () => { test("Classifies 10 cards", () => {   assert.equal(getCardValue("10♠"), 10); }); -// TODO: What other invalid card cases can you think of? -//Invalid Rank or -//Invalid String -////Out of range input -//Input: (Rank) "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" and (Suit), also invalid input -//Input type: String -//Process Turn input into Num : "A" to 11 ; ("J", "Q", "K") to 10 -//Output : a valid Num , or invalid throw error -//const rank -//const suit -//Edge cases 0: not string -//Edge cases 1: ANy first letter which is not a Rank; -//Edge cases 2: Any second character which is not a Suit -//Edge cases 3: Both Rank plus Suit input invalid; From e080158a0604977e46ac92d2797aaa1fabb422ea Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 07:04:35 +0000 Subject: [PATCH 28/32] remove commented-out test cases for angle classification for clarity --- .../1-get-angle-type.test.js | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index e78ab51c3..346d6edd8 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -43,32 +43,3 @@ test(`should return "Invalid angle" when (angle <= 0 or angle >= 360)`, () => { expect(getAngleType(-0.5)).toEqual("Invalid angle"); }); -//test("Classifies right angles", () => { -// const right = getAngleType(90); - -//test("Classifies obtuse angles", () => { -// const right = getAngleType(91); - -//test("Classifies obtuse angles", () => { -// const right = getAngleType(179); - -//test("Classifies Straight angles", () => { -// const right = getAngleType(180); - -//test("Classifies Reflex angles", () => { -// const right = getAngleType(181); - -//test("Classifies Reflex angles", () => { -// const right = getAngleType(359); - -//test("Classifies Reflex angles", () => { -// const right = getAngleType(360); - -//test("Classifies Invalid angles", () => { -// const right = getAngleType(361); - -//test("Classifies Invalid angles", () => { -// const right = getAngleType(361); - -//test("Classifies Invalid angles", () => { -// const right = getAngleType(-1); From cabb2695936908a25484a49c70a25147e9001540 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 07:18:13 +0000 Subject: [PATCH 29/32] apply formatter setting --- .../2-is-proper-fraction.test.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index ef0d731a5..29d2c10fc 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -3,92 +3,92 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. // Special case: numerator is zero -test('should throw error when denominator is zero', () => { +test("should throw error when denominator is zero", () => { expect(() => isProperFraction(1, 0)).toThrow(Error); }); // Case1: numerator is zero -test('should return true when numerator is zero', () => { +test("should return true when numerator is zero", () => { expect(isProperFraction(0, 2)).toEqual(true); -}); +}); // Case2: denominator is Infinity -test('should throw TypeError when denominator is infinity', () => { +test("should throw TypeError when denominator is infinity", () => { expect(() => isProperFraction(1, Infinity)).toThrow(TypeError); }); // Case3: numerator is Infinity -test('should throw TypeError when numerator is Infinity', () => { - expect(() => isProperFraction(Number.POSITIVE_INFINITY, 2)).toThrow(TypeError); +test("should throw TypeError when numerator is Infinity", () => { + expect(() => isProperFraction(Number.POSITIVE_INFINITY, 2)).toThrow( + TypeError + ); }); // Case4: denominator is not a number -test('should throw TypeError when denominator is not a number', () => { +test("should throw TypeError when denominator is not a number", () => { expect(() => isProperFraction(1, "2")).toThrow(TypeError); expect(() => isProperFraction(2, "3")).toThrow(TypeError); expect(() => isProperFraction(3, "1")).toThrow(TypeError); }); // Case5: numerator is not a number -test('should throw TypeError when numerator is not a number', () => { +test("should throw TypeError when numerator is not a number", () => { expect(() => isProperFraction("1", 2)).toThrow(TypeError); expect(() => isProperFraction("2", 3)).toThrow(TypeError); expect(() => isProperFraction("3", 2)).toThrow(TypeError); }); // Case6: improper fraction with positive numerator and denominator -test('should return false for improper fraction', () => { +test("should return false for improper fraction", () => { expect(isProperFraction(3, 2)).toEqual(false); expect(isProperFraction(5, 3)).toEqual(false); expect(isProperFraction(10, 5)).toEqual(false); }); // Case7: equal numerator and denominator -test('should return false for equal numerator and denominator', () => { +test("should return false for equal numerator and denominator", () => { expect(isProperFraction(2, 2)).toEqual(false); expect(isProperFraction(5, 5)).toEqual(false); expect(isProperFraction(10, 10)).toEqual(false); }); // Case8: equal numerator and negative denominator -test('should return false for equal numerator and negative denominator', () => { +test("should return false for equal numerator and negative denominator", () => { expect(isProperFraction(2, -2)).toEqual(false); expect(isProperFraction(5, -5)).toEqual(false); expect(isProperFraction(10, -10)).toEqual(false); }); // Case9: negative improper fraction with positive denominator -test('should return false for negative improper fraction', () => { +test("should return false for negative improper fraction", () => { expect(isProperFraction(-3, 2)).toEqual(false); expect(isProperFraction(-5, 3)).toEqual(false); expect(isProperFraction(-10, 5)).toEqual(false); }); // Case10: negative improper fraction with negative numerator -test('should return true for negative proper fraction', () => { +test("should return true for negative proper fraction", () => { expect(isProperFraction(-1, 2)).toEqual(true); expect(isProperFraction(-2, 3)).toEqual(true); expect(isProperFraction(-3, 4)).toEqual(true); }); // Case11: proper fraction with negative denominator -test('should return true for proper fraction with negative denominator', () => { +test("should return true for proper fraction with negative denominator", () => { expect(isProperFraction(1, -2)).toEqual(true); expect(isProperFraction(2, -3)).toEqual(true); expect(isProperFraction(3, -4)).toEqual(true); }); // Case12: improper fraction with negative denominator -test('should return false for improper fraction with negative denominator', () => { +test("should return false for improper fraction with negative denominator", () => { expect(isProperFraction(3, -2)).toEqual(false); expect(isProperFraction(5, -3)).toEqual(false); expect(isProperFraction(10, -5)).toEqual(false); }); // Case13: proper fraction with both negative numerator and denominator -test('should return true for proper fraction with both negative numerator and denominator', () => { +test("should return true for proper fraction with both negative numerator and denominator", () => { expect(isProperFraction(-1, -2)).toEqual(true); expect(isProperFraction(-2, -3)).toEqual(true); expect(isProperFraction(-3, -4)).toEqual(true); }); // Case14: improper fraction with both negative numerator and denominator -test('should return false for improper fraction with both negative numerator and denominator', () => { +test("should return false for improper fraction with both negative numerator and denominator", () => { expect(isProperFraction(-3, -2)).toEqual(false); expect(isProperFraction(-5, -3)).toEqual(false); expect(isProperFraction(-10, -5)).toEqual(false); }); // Case15: proper fraction with positive numerator and denominator -test('should return true for proper fraction', () => { +test("should return true for proper fraction", () => { expect(isProperFraction(1, 2)).toEqual(true); expect(isProperFraction(2, 3)).toEqual(true); }); - - From 848b4002fdfa64610f0ff75e2e3f103977566b1d Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 08:05:42 +0000 Subject: [PATCH 30/32] format files with Prettier in getAngleType function --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 15244eddc..37c205023 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -17,8 +17,6 @@ // execute the code to ensure all tests pass. export function getAngleType(angle) { - - if (angle <= 0 || angle >= 360) { return `Invalid angle`; } From 298c3e0cf781f3438295ff6ac247bb90d80ea944 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 08:33:00 +0000 Subject: [PATCH 31/32] apply formatter to remove unnecessary blank line from invalid angle test case --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 346d6edd8..e2f885e19 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -42,4 +42,3 @@ test(`should return "Invalid angle" when (angle <= 0 or angle >= 360)`, () => { expect(getAngleType(361)).toEqual("Invalid angle"); expect(getAngleType(-0.5)).toEqual("Invalid angle"); }); - From 7b19bc2667085314db985a00d0789bf0ea701094 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 28 Oct 2026 08:33:54 +0000 Subject: [PATCH 32/32] apply formatter to remove unnecessary blank line from get-card-value test --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 06c8d1531..50b050f86 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -59,7 +59,6 @@ test(`Should throw an error for edge cases`, () => { expect(() => getCardValue("10♠♣")).toThrow(Error); }); - // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) @@ -68,4 +67,3 @@ test(`Should throw an error for edge cases`, () => { // 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 -