@@ -8,6 +8,27 @@ test("should return 11 for Ace of Spades", () => {
88} ) ;
99
1010// Case 2: Handle Number Cards (2-10):
11+ test ( "should return correct value for number cards" , ( ) => {
12+ expect ( getCardValue ( "2♣" ) ) . toEqual ( 2 ) ;
13+ expect ( getCardValue ( "5♦" ) ) . toEqual ( 5 ) ;
14+ expect ( getCardValue ( "10♥" ) ) . toEqual ( 10 ) ;
15+ } )
1116// Case 3: Handle Face Cards (J, Q, K):
17+ test ( "should return 10 for face cards" , ( ) => {
18+ expect ( getCardValue ( "J♣" ) ) . toEqual ( 10 ) ;
19+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
20+ expect ( getCardValue ( "K♥" ) ) . toEqual ( 10 ) ;
21+ } )
1222// Case 4: Handle Ace (A):
23+ test ( "should return 11 for Ace cards" , ( ) => {
24+ expect ( getCardValue ( "A♣" ) ) . toEqual ( 11 ) ;
25+ expect ( getCardValue ( "A♦" ) ) . toEqual ( 11 ) ;
26+ expect ( getCardValue ( "A♥" ) ) . toEqual ( 11 ) ;
27+ } )
1328// Case 5: Handle Invalid Cards:
29+ test ( "should return Invalid card rank for invalid cards" , ( ) => {
30+ expect ( getCardValue ( "1♣" ) ) . toEqual ( "Invalid card rank." ) ;
31+ expect ( getCardValue ( "11♦" ) ) . toEqual ( "Invalid card rank." ) ;
32+ expect ( getCardValue ( "3" ) ) . toEqual ( "Invalid card rank." ) ;
33+ expect ( getCardValue ( "3😄" ) ) . toEqual ( "Invalid card rank." ) ;
34+ } )
0 commit comments