@@ -8,6 +8,32 @@ test("should return 11 for Ace of Spades", () => {
88} ) ;
99
1010// Case 2: Handle Number Cards (2-10):
11+ // When the card is a number between 2 and 10,
12+ // Then the function should return the numeric value of the card
13+ test ( "should return numeric value for number cards 2-10" , ( ) => {
14+ expect ( getCardValue ( "5♥" ) ) . toEqual ( 5 ) ;
15+ expect ( getCardValue ( "10♦" ) ) . toEqual ( 10 ) ;
16+ } ) ;
17+
1118// Case 3: Handle Face Cards (J, Q, K):
19+ // When the card is J, Q, or K,
20+ // Then the function should return 10
21+ test ( "should return 10 for face cards J, Q, K" , ( ) => {
22+ expect ( getCardValue ( "J♣" ) ) . toEqual ( 10 ) ;
23+ expect ( getCardValue ( "Q♠" ) ) . toEqual ( 10 ) ;
24+ expect ( getCardValue ( "K♦" ) ) . toEqual ( 10 ) ;
25+ } ) ;
26+
1227// Case 4: Handle Ace (A):
28+ // When the card is an Ace,
29+ // Then the function should return 11
30+ test ( "should return 11 for Ace cards" , ( ) => {
31+ expect ( getCardValue ( "A♥" ) ) . toEqual ( 11 ) ;
32+ } ) ;
33+
1334// Case 5: Handle Invalid Cards:
35+ // When the card has an invalid rank,
36+ // Then the function should throw an error
37+ test ( "should throw an error for invalid cards" , ( ) => {
38+ expect ( ( ) => getCardValue ( "Z♠" ) ) . toThrow ( "Invalid card rank." ) ;
39+ } ) ;
0 commit comments