Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
else return false;
// add your completed function from key-implement here
}
if (denominator === 0) return false;
return Math.abs(numerator) < Math.abs(denominator);
}
// function isProperFraction(numerator, denominator) {
// if (numerator < denominator) return true;
// else return false;
// // add your completed function from key-implement here
// }



module.exports = isProperFraction;
4 changes: 2 additions & 2 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ test("should return true for a proper fraction", () => {
expect(isProperFraction(2, 3)).toEqual(true);
expect(isProperFraction(5, 2)).toEqual(false);
expect(isProperFraction(5, -2)).toEqual(false);
expect(isProperFraction(-5, 2)).toEqual(true);
expect(isProperFraction(-5, -2)).toEqual(true);
expect(isProperFraction(-5, 2)).toEqual(false);
expect(isProperFraction(-5, -2)).toEqual(false);
});


Expand Down
7 changes: 3 additions & 4 deletions Sprint-3/2-mandatory-rewrite/3-get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
function getCardValue(card) {
const rank = card.slice(0, -1);
if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10;
if (rank >= "2" && rank <= "9") return parseInt(rank);
throw new Error("Invalid");
if (["J", "Q", "K", "10"].includes(rank)) return 10;
if (/^[2-9]$/.test(rank)) return Number(rank);
throw new Error("Invalid")
}



module.exports = getCardValue;
12 changes: 10 additions & 2 deletions Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ expect(handleAce).toEqual(11);
});

// // Case 5: Handle Invalid Cards:
// test("Handle Ace (A)", () => {
// const handleAce = getCardValue("29♠");
// expect(handleAce).toEqual("Invalid");
// });

//Case 5: Handle Invalid Cards:
test("Handle Invalid Cards", () => {
expect(() => getCardValue("Z♥")).toThrow("Invalid");
});
expect(() => getCardValue("Z♥")).toThrow("Invalid");
expect(() => getCardValue("29♠")).toThrow("Invalid");
expect(() => getCardValue("2.1♠")).toThrow("Invalid");
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getOrdinalNumber = require("./get-ordinal-number");



test("should return '3rd' for 3 and more", () => {
test("should return all mentioned test bellow", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description does not tell what is being tested in this particular test.

When there is an error, Jest will display this message but not all of the code at lines 14-16. The person running the test would have to take an extra step to view the code in the test script to find out what the tests are about.

expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(23)).toEqual("23rd");
Expand Down