Skip to content

Commit 0b2a485

Browse files
added module.exports
1 parent 809e11b commit 0b2a485

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ try {
8181
console.log("Test failed: Expected an error for invalid card rank.");
8282
} catch(error){
8383
assertEquals(error.message, "Invalid card rank.");
84-
}
84+
}
85+
module.exports = getCardValue;

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,29 @@ test("should return 11 for Ace of Spades", () => {
77
expect(aceofSpades).toEqual(11);
88
});
99

10-
// Case 2: Handle Number Cards (2-10):
10+
test("should return the correct value for number cards between 2 and 9", () => {
11+
expect(getCardValue("2♥")).toEqual(2);
12+
expect(getCardValue("3♦")).toEqual(3);
13+
expect(getCardValue("4♣")).toEqual(4);
14+
expect(getCardValue("5♠")).toEqual(5);
15+
expect(getCardValue("6♥")).toEqual(6);
16+
expect(getCardValue("7♦")).toEqual(7);
17+
expect(getCardValue("8♣")).toEqual(8);
18+
expect(getCardValue("9♠")).toEqual(9);
19+
expect(getCardValue("10♥")).toEqual(10);
20+
});
1121
// Case 3: Handle Face Cards (J, Q, K):
22+
test("should return 10 for face cards (J, Q, K)", () => {
23+
expect(getCardValue("J♠")).toEqual(10);
24+
expect(getCardValue("Q♦")).toEqual(10);
25+
expect(getCardValue("K♣")).toEqual(10);
26+
});
1227
// Case 4: Handle Ace (A):
28+
test("should return 11 for Aces", () => {
29+
expect(getCardValue("A♠")).toEqual(11);
30+
});
1331
// Case 5: Handle Invalid Cards:
32+
test("should throw an error for invalid card ranks", () => {
33+
expect(() => getCardValue("X♠")).toThrow("Invalid card rank.");
34+
expect(() => getCardValue("1♠")).toThrow("Invalid card rank.");
35+
});

0 commit comments

Comments
 (0)