From a847980402205586575e8c9ae2d32aa7873da821 Mon Sep 17 00:00:00 2001 From: Enice-Codes Date: Thu, 13 Aug 2026 01:19:48 +0200 Subject: [PATCH 1/5] Complete Sprint 3 implement-and-rewrite exercises --- .../implement/1-get-angle-type.js | 35 +++++++++++-- .../implement/2-is-proper-fraction.js | 20 ++++++++ .../implement/3-get-card-value.js | 50 +++++++++++++++++-- .../1-get-angle-type.test.js | 25 +++++++++- .../2-is-proper-fraction.test.js | 14 ++++++ .../3-get-card-value.test.js | 22 ++++++-- 6 files changed, 154 insertions(+), 12 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e2..19140f90a8 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -1,3 +1,4 @@ + // Implement a function getAngleType // // When given an angle in degrees, it should return a string indicating the type of angle: @@ -13,9 +14,19 @@ // Acceptance criteria: // After you have implemented the function, write tests to cover all the cases, and // execute the code to ensure all tests pass. - function 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 +45,22 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles const right = getAngleType(90); -assertEquals(right, "Right angle"); +assertEquals(right, "right angle"); + +const acute = getAngleType(45); +assertEquals(acute, 'Acute angle'); + +const obtuse = getAngleType(120); +assertEquals(obtuse,'obtuse angle') + +const straight = getAngleType(180); +assertEquals(straight, 'straight angle'); + +const reflex = getAngleType(270); +assertEquals(reflex, 'reflex angle'); + +const invalid1 = getAngleType(-10); +assertEquals(invalid1, 'Invalid angle'); + +const invalid2 = getAngleType(400); +assertEquals(invalid2, 'Invalid angle'); \ No newline at end of file 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..7fa94535da 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,14 @@ 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 +39,15 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); + +// example: 4/3 is not a proper fraction +assertEquals(isProperFraction(4, 3), false); + +// example: 6/5 is not a proper fraction +assertEquals(isProperFraction(6, 5), false); + +// example: 0/5 is a proper fraction +assertEquals(isProperFraction(0, 5), true); + +// example: 5/0 is not a proper fraction +assertEquals(isProperFraction(5, 0), false); \ No newline at end of file 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..edf7449283 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,23 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + const rank = card.slice(0, -1); // everything except the last character (suit) + const validSuits = ["♠", "♥", "♦", "♣"]; + const suit = card.slice(-1); + + if (!validSuits.includes(suit)) { + throw new Error("Invalid card"); + } + + if (rank === "A") { + return 11; + } else if (rank === "J" || rank === "Q" || rank === "K") { + return 10; + } else if (["2","3","4","5","6","7","8","9","10"].includes(rank)) { + return Number(rank); + } else { + throw new Error("Invalid card"); + } } // The line below allows us to load the getCardValue function into tests in other files. @@ -46,9 +62,37 @@ 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 😢"); + console.error("Error was not thrown for invalid card "); } catch (e) { - console.log("Error thrown for invalid card 🎉"); + console.log("Error thrown for invalid card "); } +assertEquals(getCardValue("A♠"), 11); +assertEquals(getCardValue("J♣"), 10); +assertEquals(getCardValue("Q♦"), 10); +assertEquals(getCardValue("K♥"), 10); +assertEquals(getCardValue("2♠"), 2); +assertEquals(getCardValue("3♥"), 3); + +// What other valid card cases can you think of? +function assertEqual(func, message) { + try { + func(); + console.log("Valid card test passed: " + message); + } catch (e) { + console.error("Valid card test failed: " + message + " — " + e.message); + } +} // What other invalid card cases can you think of? + function assertThrows(func, errorMessage) { + try { + func(); + console.error("Error was not thrown "); + } catch (e) { + if (e.message === errorMessage) { + console.log("Error thrown as expected "); + } else { + console.error(`Unexpected error message: ${e.message}`); + } + } +} \ No newline at end of file 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..33af2c967a 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 @@ -6,7 +6,7 @@ const getAngleType = require("../implement/1-get-angle-type"); // including boundary and invalid cases. // Case 1: Acute angles -test(`should return "Acute angle" when (0 < angle < 90)`, () => { +test(`should return "Acute angle" when (0 < angle && angle < 90)`, () => { // Test various acute angles, including boundary cases expect(getAngleType(1)).toEqual("Acute angle"); expect(getAngleType(45)).toEqual("Acute angle"); @@ -14,7 +14,28 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test (`should return "right angle" when (angle === 90)`,() => { + // testing various angles ,including boundary cases + expect( getAngleType(90)).toEqual("right angle"); + }); // Case 3: Obtuse angles +test (`should return "obtuse angle" when (90 < angle && angle < 180)`, () => { +expect(getAngleType(91)).toEqual("obtuse angle"); +expect(getAngleType(125)).toEqual("obtuse angle"); +expect(getAngleType(172)).toEqual("obtuse angle"); +}); // Case 4: Straight angle -// Case 5: Reflex angles +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 && angle < 360)`, () => { + expect(getAngleType(181)).toEqual("reflex angle"); + expect(getAngleType(270)).toEqual("reflex angle"); + expect(getAngleType(359)).toEqual("reflex angle"); +}); // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle < 0 || angle > 360)`, () => { + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle"); +}); 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..69cda3bf52 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); }); + +// special case : numerator is one +test(` should return true when the numerator is one and denominator is greater than one`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); +// special case : denominator is negative to the numerator +test(`should return false when the denominator is negative and the numerator is positive`, () => { + expect(isProperFraction(1, -2)).toEqual(false); +}); + +// special case : denominator is negative to the numerator +test(`should return false when the numerator is negative and the denominator is positive`, () => { + expect(isProperFraction(-1, 2)).toEqual(false); +}); \ No newline at end of file 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..3786982ab6 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,10 +9,24 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); -// Suggestion: Group the remaining test data into these categories: -// Number Cards (2-10) -// Face Cards (J, Q, K) -// Invalid Cards +// 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 when given a number card`, () => { + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("5♥")).toEqual(5); + expect(getCardValue("10♦")).toEqual(10); +}); + +// Case 4: Invalid Cards +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("invalid")).toThrow("Invalid card"); +}); // To learn how to test whether a function throws an error as expected in Jest, // please refer to the Jest documentation: From 534fa296dd312de7fc02ef4a25443eed0cd8efd3 Mon Sep 17 00:00:00 2001 From: Enice-Codes Date: Tue, 18 Aug 2026 18:59:10 +0200 Subject: [PATCH 2/5] reviewed proper fraction --- .../2-is-proper-fraction.test.js | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 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 69cda3bf52..2dfc4d2aca 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 @@ -2,23 +2,38 @@ // We will use the same function, but write tests for it using Jest in this file. 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 -test(`should return false when denominator is zero`, () => { +test("returns false when denominator is zero", () => { expect(isProperFraction(1, 0)).toEqual(false); }); - -// special case : numerator is one -test(` should return true when the numerator is one and denominator is greater than one`, () => { + +test("returns true for a positive proper fraction", () => { expect(isProperFraction(1, 2)).toEqual(true); }); -// special case : denominator is negative to the numerator -test(`should return false when the denominator is negative and the numerator is positive`, () => { - expect(isProperFraction(1, -2)).toEqual(false); + +test("returns true when numerator is negative and denominator is positive", () => { + expect(isProperFraction(-1, 2)).toEqual(true); +}); + +test("returns true when numerator is positive and denominator is negative", () => { + expect(isProperFraction(1, -2)).toEqual(true); +}); + +test("returns true when both numerator and denominator are negative", () => { + expect(isProperFraction(-1, -2)).toEqual(true); +}); + +test("returns true when numerator is zero and denominator is non-zero", () => { + expect(isProperFraction(0, 5)).toEqual(true); +}); + +test("returns false when numerator and denominator are equal", () => { + expect(isProperFraction(2, 2)).toEqual(false); +}); + +test("returns false when numerator is greater than denominator", () => { + expect(isProperFraction(3, 2)).toEqual(false); }); -// special case : denominator is negative to the numerator -test(`should return false when the numerator is negative and the denominator is positive`, () => { - expect(isProperFraction(-1, 2)).toEqual(false); +test("returns false for a negative improper fraction", () => { + expect(isProperFraction(-3, 2)).toEqual(false); }); \ No newline at end of file From fcea904f5685f5ca83279af9bc4bc6e1c3818210 Mon Sep 17 00:00:00 2001 From: Enice-Codes Date: Tue, 18 Aug 2026 19:10:59 +0200 Subject: [PATCH 3/5] made sure all the output of the function follow the same alphabet casing --- .../1-get-angle-type.test.js | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 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 33af2c967a..67726029e3 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 @@ -1,41 +1,33 @@ // This statement loads the getAngleType function you wrote in the implement directory. -// We will use the same function, but write tests for it using Jest in this file. const getAngleType = require("../implement/1-get-angle-type"); -// TODO: Write tests in Jest syntax to cover all cases/outcomes, -// including boundary and invalid cases. +test("returns acute angle for angles between 0 and 90", () => { + expect(getAngleType(1)).toEqual("acute angle"); + expect(getAngleType(45)).toEqual("acute angle"); + expect(getAngleType(89)).toEqual("acute angle"); +}); -// Case 1: Acute angles -test(`should return "Acute angle" when (0 < angle && 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"); +test("returns right angle for 90 degrees", () => { + expect(getAngleType(90)).toEqual("right angle"); }); -// Case 2: Right angle -test (`should return "right angle" when (angle === 90)`,() => { - // testing various angles ,including boundary cases - expect( getAngleType(90)).toEqual("right angle"); - }); -// Case 3: Obtuse angles -test (`should return "obtuse angle" when (90 < angle && angle < 180)`, () => { -expect(getAngleType(91)).toEqual("obtuse angle"); -expect(getAngleType(125)).toEqual("obtuse angle"); -expect(getAngleType(172)).toEqual("obtuse angle"); +test("returns obtuse angle for angles between 90 and 180", () => { + expect(getAngleType(91)).toEqual("obtuse angle"); + expect(getAngleType(125)).toEqual("obtuse angle"); + expect(getAngleType(172)).toEqual("obtuse angle"); }); -// Case 4: Straight angle -test(`should return "straight angle" when (angle === 180)`, () => { + +test("returns straight angle for 180 degrees", () => { expect(getAngleType(180)).toEqual("straight angle"); }); -// Case 5: Reflex angles\ -test(`should return "reflex angle" when (180 < angle && angle < 360)`, () => { + +test("returns reflex angle for angles between 180 and 360", () => { expect(getAngleType(181)).toEqual("reflex angle"); expect(getAngleType(270)).toEqual("reflex angle"); expect(getAngleType(359)).toEqual("reflex angle"); }); -// Case 6: Invalid angles -test(`should return "Invalid angle" when (angle < 0 || angle > 360)`, () => { - expect(getAngleType(-1)).toEqual("Invalid angle"); - expect(getAngleType(361)).toEqual("Invalid angle"); -}); + +test("returns invalid angle for angles outside the valid range", () => { + expect(getAngleType(-1)).toEqual("invalid angle"); + expect(getAngleType(361)).toEqual("invalid angle"); +}); \ No newline at end of file From 57f15f88b5f29bb19ea46c8d5d8bcb5f3aa1d08f Mon Sep 17 00:00:00 2001 From: Enice-Codes Date: Tue, 18 Aug 2026 20:30:07 +0200 Subject: [PATCH 4/5] implemented correct code --- .../3-get-card-value.test.js | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 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 3786982ab6..a319c4d428 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 @@ -2,33 +2,27 @@ // We will use the same function, but write tests for it using Jest in this file. const getCardValue = require("../implement/3-get-card-value"); -// TODO: Write tests in Jest syntax to cover all possible outcomes. - -// Case 1: Ace (A) -test(`Should return 11 when given an ace card`, () => { +test("returns 11 for an ace", () => { expect(getCardValue("A♠")).toEqual(11); }); -// case 2 : face cards (J, Q, K) -test(`Should return 10 when given a face card`, () => { +test("returns 10 for face cards", () => { 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 when given a number card`, () => { +test("returns the correct value for number cards", () => { expect(getCardValue("2♠")).toEqual(2); expect(getCardValue("5♥")).toEqual(5); expect(getCardValue("10♦")).toEqual(10); }); -// Case 4: Invalid Cards -test(`Should throw an error when given an invalid card`, () => { +test("throws an error for invalid cards", () => { expect(() => getCardValue("invalid")).toThrow("Invalid 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 - + expect(() => getCardValue("")).toThrow("Invalid card"); + expect(() => getCardValue("1♠")).toThrow("Invalid card"); + expect(() => getCardValue("11♠")).toThrow("Invalid card"); + expect(() => getCardValue("A")).toThrow("Invalid card"); + expect(() => getCardValue("X♠")).toThrow("Invalid card"); +}); \ No newline at end of file From 7c0d8f569ed21ad7416ab0e4b65099a04e3d9565 Mon Sep 17 00:00:00 2001 From: Enice-Codes Date: Tue, 18 Aug 2026 20:44:36 +0200 Subject: [PATCH 5/5] complete implement and rewrite tests exercises --- .../implement/1-get-angle-type.js | 58 +++++++------------ .../implement/2-is-proper-fraction.js | 34 +++++------ 2 files changed, 33 insertions(+), 59 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 19140f90a8..3db49108aa 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,26 +15,23 @@ // After you have implemented the function, write tests to cover all the cases, and // execute the code to ensure all tests pass. function getAngleType(angle) { - 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"; + 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. -// This will be useful in the "rewrite tests with jest" step. module.exports = getAngleType; -// This helper function is written to make our assertions easier to read. -// If the actual output matches the target output, the test will pass function assertEquals(actualOutput, targetOutput) { console.assert( actualOutput === targetOutput, @@ -42,25 +39,10 @@ function assertEquals(actualOutput, targetOutput) { ); } -// TODO: Write tests to cover all cases, including boundary and invalid cases. -// Example: Identify Right Angles -const right = getAngleType(90); -assertEquals(right, "right angle"); - -const acute = getAngleType(45); -assertEquals(acute, 'Acute angle'); - -const obtuse = getAngleType(120); -assertEquals(obtuse,'obtuse angle') - -const straight = getAngleType(180); -assertEquals(straight, 'straight angle'); - -const reflex = getAngleType(270); -assertEquals(reflex, 'reflex angle'); - -const invalid1 = getAngleType(-10); -assertEquals(invalid1, 'Invalid angle'); - -const invalid2 = getAngleType(400); -assertEquals(invalid2, 'Invalid angle'); \ No newline at end of file +assertEquals(getAngleType(45), "acute angle"); +assertEquals(getAngleType(90), "right angle"); +assertEquals(getAngleType(120), "obtuse angle"); +assertEquals(getAngleType(180), "straight angle"); +assertEquals(getAngleType(270), "reflex angle"); +assertEquals(getAngleType(-10), "invalid angle"); +assertEquals(getAngleType(400), "invalid angle"); \ No newline at end of file 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 7fa94535da..7e4630c066 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,22 +11,15 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function - if (denominator === 0){ + if (denominator === 0) { return false; - } - if (numerator < denominator && numerator > 0){ - return true; - } - return false; + + return Math.abs(numerator) < Math.abs(denominator); } -// The line below allows us to load the isProperFraction function into tests in other files. -// This will be useful in the "rewrite tests with jest" step. module.exports = isProperFraction; -// Here's our helper again function assertEquals(actualOutput, targetOutput) { console.assert( actualOutput === targetOutput, @@ -34,20 +27,19 @@ function assertEquals(actualOutput, targetOutput) { ); } -// TODO: Write tests to cover all cases. -// What combinations of numerators and denominators should you test? - -// Example: 1/2 is a proper fraction +// Proper fractions assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(0, 5), true); +assertEquals(isProperFraction(-1, 2), true); +assertEquals(isProperFraction(1, -2), true); +assertEquals(isProperFraction(-1, -2), true); -// example: 4/3 is not a proper fraction +// Improper fractions assertEquals(isProperFraction(4, 3), false); - -// example: 6/5 is not a proper fraction assertEquals(isProperFraction(6, 5), false); +assertEquals(isProperFraction(-4, 3), false); +assertEquals(isProperFraction(4, -3), false); +assertEquals(isProperFraction(-4, -3), false); -// example: 0/5 is a proper fraction -assertEquals(isProperFraction(0, 5), true); - -// example: 5/0 is not a proper fraction +// Zero denominator assertEquals(isProperFraction(5, 0), false); \ No newline at end of file