Skip to content

Commit 78c404f

Browse files
committed
Add Jest tests for getCardValue function covering numbers, face cards, Ace, and invalid cards
1 parent 75fdb2a commit 78c404f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ test("should return 11 for Ace of Spades", () => {
88
});
99

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return the value of number cards", () => {
12+
expect(getCardValue("2♣")).toEqual(2);
13+
expect(getCardValue("5♠")).toEqual(5);
14+
expect(getCardValue("10♦")).toEqual(10);
15+
});
16+
1117
// Case 3: Handle Face Cards (J, Q, K):
12-
// Case 4: Handle Ace (A):
18+
test("should return 10 for face cards", () => {
19+
expect(getCardValue("J♣")).toEqual(10);
20+
expect(getCardValue("Q♥")).toEqual(10);
21+
expect(getCardValue("K♠")).toEqual(10);
22+
});
23+
1324
// Case 5: Handle Invalid Cards:
25+
test("should throw an error for Invalid card", () => {
26+
expect(() => getCardValue("1♣")).toThrow("Invalid card rank.");
27+
});

0 commit comments

Comments
 (0)