Skip to content

Commit fad2100

Browse files
committed
Edited incorrect test cases and fixed logic to ensure all tests pass successfully.
1 parent dbf4e92 commit fad2100

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-22
lines changed

Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ test("should return true for a proper fraction", () => {
55
});
66

77
// Case 2: Identify Improper Fractions:
8-
9-
const improperFraction = isProperFraction(5, 2);
10-
assertEquals(improperFraction, false); // improper fraction is the fraction where the numerator is greater than or equal to the denominator.
8+
test("should return false for improper fractions", () => {
9+
const improperFraction = isProperFraction(5, 2);
10+
expect(improperFraction).toEqual(false);
11+
});
1112

1213
// Case 3: Identify Negative Fractions:
13-
14-
const negativeFraction = isProperFraction(-4, 7);
15-
assertEquals(negativeFraction, true); // negative fraction is the fraction where the absolute value of the numerator is less than the denominator.
14+
test("should return true for negative fractions", () => {
15+
const negativeFraction = isProperFraction(-4, 7);
16+
expect(negativeFraction).toEqual(true);
17+
});
1618

1719
// Case 4: Identify Equal Numerator and Denominator:
18-
19-
const equalFraction = isProperFraction(3, 3);
20-
assertEquals(equalFraction, false); // equal fraction is the fraction where the numerator is equal to the denominator.
20+
test("should return false for equal numerator and denominator", () => {
21+
const equalFraction = isProperFraction(3, 3);
22+
expect(equalFraction).toEqual(false);
23+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
function getCardValue(card) {
2+
const rank = card.slice(0, -1); // get the value part: A, 2–10, J, Q, K
3+
24
if (rank === "A") return 11;
5+
if (["K", "Q", "J"].includes(rank)) return 10;
6+
7+
const number = parseInt(rank);
8+
if (!isNaN(number) && number >= 2 && number <= 10) return number;
9+
10+
throw new Error("Invalid card");
311
}
12+
413
module.exports = getCardValue;

Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,30 @@ test("should return 11 for Ace of Spades", () => {
55
expect(aceofSpades).toEqual(11);
66
});
77

8-
const aceofSpades = getCardValue("A♠");
9-
assertEquals(aceofSpades, 11);
10-
11-
const fiveofHearts = getCardValue("5♥");
12-
assertEquals(fiveofHearts, 5);
8+
test("should return 5 for 5 of Hearts", () => {
9+
const fiveofHearts = getCardValue("5♥");
10+
expect(fiveofHearts).toEqual(5);
11+
});
1312

14-
const tenofDiamonds = getCardValue("10♦");
15-
assertEquals(tenofDiamonds, 10);
13+
test("should return 10 for 10 of Diamonds", () => {
14+
const tenofDiamonds = getCardValue("10♦");
15+
expect(tenofDiamonds).toEqual(10);
16+
});
1617

17-
const jackofClubs = getCardValue("J♣");
18-
assertEquals(jackofClubs, 10);
18+
test("should return 10 for Jack of Clubs", () => {
19+
const jackofClubs = getCardValue("J♣");
20+
expect(jackofClubs).toEqual(10);
21+
});
1922

20-
const queenofHearts = getCardValue("Q♥");
21-
assertEquals(queenofHearts, 10);
23+
test("should return 10 for Queen of Hearts", () => {
24+
const queenofHearts = getCardValue("Q♥");
25+
expect(queenofHearts).toEqual(10);
26+
});
2227

23-
const kingofSpades = getCardValue("K♠");
24-
assertEquals(kingofSpades, 10);
28+
test("should return 10 for King of Spades", () => {
29+
const kingofSpades = getCardValue("K♠");
30+
expect(kingofSpades).toEqual(10);
31+
});
2532

2633
try {
2734
getCardValue("Z♠");

0 commit comments

Comments
 (0)