Skip to content

Commit 356b64f

Browse files
committed
Complete getCardValue exercise
1 parent 8930945 commit 356b64f

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

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

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,46 @@
33
const getCardValue = require("../implement/3-get-card-value");
44

55
test("should return 11 for Ace of Spades", () => {
6-
const aceofSpades = getCardValue("A♠");
7-
expect(aceofSpades).toEqual(11);
6+
const aceOfSpades = getCardValue("A♠");
7+
expect(aceOfSpades).toEqual(11);
88
});
99

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return 2 for 2 of hearts", () => {
12+
const twoOfHearts = getCardValue("2♥");
13+
expect(twoOfHearts).toEqual(2)
14+
})
15+
16+
test("should return 10 for 10 of Diamonds", () => {
17+
const tenOfDiamonds = getCardValue("10♦");
18+
expect(tenOfDiamonds).toEqual(10)
19+
});
20+
1121
// Case 3: Handle Face Cards (J, Q, K):
22+
23+
test("should return 10 for Jack of Clubs", () => {
24+
const jackOfClubs = getCardValue("J♣");
25+
expect(jackOfClubs).toEqual(10)
26+
});
27+
28+
test("should return 10 for Queen of Hearts", () => {
29+
const queenOfHearts = getCardValue("Q♥");
30+
expect(queenOfHearts).toEqual(10)
31+
});
32+
33+
test("should return 10 for King of Spades", () => {
34+
const kingOfSpades= getCardValue("K♠");
35+
expect(kingOfSpades).toEqual(10)
36+
});
37+
1238
// Case 4: Handle Ace (A):
39+
test("should return 11 for Ace of Spades", () => {
40+
const aceOfHearts = getCardValue("A♥");
41+
expect(aceOfHearts).toEqual(11);
42+
});
43+
1344
// Case 5: Handle Invalid Cards:
45+
46+
test("should throw an error for invalid card", () => {
47+
expect(() => getCardValue("1♣")).toThrow("invalid card rank.");
48+
});

0 commit comments

Comments
 (0)