Skip to content

Commit aa82bda

Browse files
committed
Solved task Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js
1 parent 41f0a01 commit aa82bda

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

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

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return the numeric value between '2' and '10', corresponding to the rank (e.g., '2' should return 2)", () => {
12+
const fiveOfHearts = getCardValue("5♥");
13+
expect(fiveOfHearts).toEqual(5);
14+
});
15+
1116
// Case 3: Handle Face Cards (J, Q, K):
17+
test("should return the value 10, as these cards (J, Q, K) are worth 10 points each in blackjack", () => {
18+
const jackOfClubs = getCardValue("J♣");
19+
expect(jackOfClubs).toEqual(10);
20+
const queenOfSpades = getCardValue("Q♠");
21+
expect(queenOfSpades).toEqual(10);
22+
const kingOfHearts = getCardValue("K♥");
23+
expect(kingOfHearts).toEqual(10);
24+
});
25+
1226
// Case 4: Handle Ace (A):
27+
// Actually, I guess will be better to combine all case tests for aces in one, but case for Ace of Spaces already covered in Case 1
28+
test("should return 11 for a card with a rank of 'A'", () => {
29+
const aceOfDiamonds = getCardValue("A♦");
30+
expect(aceOfDiamonds).toEqual(11);
31+
const aceOfClubs = getCardValue("A♣");
32+
expect(aceOfClubs).toEqual(11);
33+
const aceOfHearts = getCardValue("A♥");
34+
expect(aceOfHearts).toEqual(11);
35+
});
36+
1337
// Case 5: Handle Invalid Cards:
38+
test("should throw an error indicating 'Invalid card rank.' or 'Invalid card face.' when given a card with an invalid rank (neither a number nor a recognized face card)", () => {
39+
const invalidNumberCard = getCardValue("12♥");
40+
expect(invalidNumberCard).toEqual("Invalid card rank.");
41+
const invalidFaceCard = getCardValue("5*");
42+
expect(invalidFaceCard).toEqual("Invalid card face.");
43+
const invalidFaceCard10 = getCardValue("10$");
44+
expect(invalidFaceCard10).toEqual("Invalid card face.");
45+
const invalidFaceCardJack = getCardValue("J%");
46+
expect(invalidFaceCardJack).toEqual("Invalid card face.");
47+
const invalidFaceCardQueen = getCardValue("Q£");
48+
expect(invalidFaceCardQueen).toEqual("Invalid card face.");
49+
const invalidFaceCardKing = getCardValue("K^");
50+
expect(invalidFaceCardKing).toEqual("Invalid card face.");
51+
});

0 commit comments

Comments
 (0)