@@ -9,6 +9,40 @@ test(`Should return 11 when given an ace card`, () => {
99 expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
1010} ) ;
1111
12+
13+ // Case 2: Jack (J), Queen (Q), and King (K) - Face Cards
14+ test ( `Should return 10 when given a face card` , ( ) => {
15+ expect ( getCardValue ( "J♣" ) ) . toEqual ( 10 ) ;
16+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
17+ expect ( getCardValue ( "K♦" ) ) . toEqual ( 10 ) ;
18+ } ) ;
19+
20+ // Case 3: Number Cards (2-10)
21+ test ( `Should return the numeric value when given a number card` , ( ) => {
22+ expect ( getCardValue ( "2♥" ) ) . toEqual ( 2 ) ;
23+ expect ( getCardValue ( "10♥" ) ) . toEqual ( 10 ) ;
24+ expect ( getCardValue ( "3♥" ) ) . toEqual ( 3 ) ;
25+ expect ( getCardValue ( "4♥" ) ) . toEqual ( 4 ) ;
26+ expect ( getCardValue ( "5♥" ) ) . toEqual ( 5 ) ;
27+ expect ( getCardValue ( "6♥" ) ) . toEqual ( 6 ) ;
28+ expect ( getCardValue ( "7♥" ) ) . toEqual ( 7 ) ;
29+ expect ( getCardValue ( "8♥" ) ) . toEqual ( 8 ) ;
30+ expect ( getCardValue ( "9♥" ) ) . toEqual ( 9 ) ;
31+ expect ( getCardValue ( "10♥" ) ) . toEqual ( 10 ) ;
32+ } ) ;
33+
34+ // Case 4: Invalid Cards
35+ test ( `Should throw an error when given an invalid card` , ( ) => {
36+ expect ( ( ) => getCardValue ( "KK" ) ) . toThrow ( "Invalid card string" ) ;
37+ expect ( ( ) => getCardValue ( "A" ) ) . toThrow ( "Invalid card string" ) ;
38+ expect ( ( ) => getCardValue ( "2" ) ) . toThrow ( "Invalid card string" ) ;
39+ expect ( ( ) => getCardValue ( "3" ) ) . toThrow ( "Invalid card string" ) ;
40+ expect ( ( ) => getCardValue ( "44" ) ) . toThrow ( "Invalid card string" ) ;
41+ expect ( ( ) => getCardValue ( "AA1" ) ) . toThrow ( "Invalid card string" ) ;
42+ expect ( ( ) => getCardValue ( "♣" ) ) . toThrow ( "Invalid card string" ) ;
43+ expect ( ( ) => getCardValue ( "" ) ) . toThrow ( "Invalid card string" ) ;
44+ } ) ;
45+
1246// Suggestion: Group the remaining test data into these categories:
1347// Number Cards (2-10)
1448// Face Cards (J, Q, K)
0 commit comments