You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,44 @@ test("should return 11 for Ace of Spades", () => {
8
8
});
9
9
10
10
// 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
+
constfiveOfHearts=getCardValue("5♥");
13
+
expect(fiveOfHearts).toEqual(5);
14
+
});
15
+
11
16
// 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
+
constjackOfClubs=getCardValue("J♣");
19
+
expect(jackOfClubs).toEqual(10);
20
+
constqueenOfSpades=getCardValue("Q♠");
21
+
expect(queenOfSpades).toEqual(10);
22
+
constkingOfHearts=getCardValue("K♥");
23
+
expect(kingOfHearts).toEqual(10);
24
+
});
25
+
12
26
// 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
+
constaceOfDiamonds=getCardValue("A♦");
30
+
expect(aceOfDiamonds).toEqual(11);
31
+
constaceOfClubs=getCardValue("A♣");
32
+
expect(aceOfClubs).toEqual(11);
33
+
constaceOfHearts=getCardValue("A♥");
34
+
expect(aceOfHearts).toEqual(11);
35
+
});
36
+
13
37
// 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)",()=>{
0 commit comments