@@ -9,6 +9,31 @@ test(`Should return 11 when given an ace card`, () => {
99 expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
1010} ) ;
1111
12+ // Case 2: Number Cards (2-10)
13+ test ( "Should return the matching numeric value for number cards (2-10)" , ( ) => {
14+ expect ( getCardValue ( "2♥" ) ) . toEqual ( 2 ) ;
15+ expect ( getCardValue ( "5♦" ) ) . toEqual ( 5 ) ;
16+ expect ( getCardValue ( "10♣" ) ) . toEqual ( 10 ) ;
17+ } ) ;
18+
19+ // Case 3: Face Cards (J, Q, K)
20+ test ( "Should return 10 when given face cards (J, Q, K)" , ( ) => {
21+ expect ( getCardValue ( "J♣" ) ) . toEqual ( 10 ) ;
22+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
23+ expect ( getCardValue ( "K♠" ) ) . toEqual ( 10 ) ;
24+ } ) ;
25+
26+ // Case 4: Invalid Cards
27+
28+ test ( "Should throw an error when given invalid card inputs" , ( ) => {
29+ expect ( ( ) => getCardValue ( "invalid" ) ) . toThrow ( ) ;
30+ expect ( ( ) => getCardValue ( "A" ) ) . toThrow ( ) ;
31+ expect ( ( ) => getCardValue ( "♠" ) ) . toThrow ( ) ;
32+ expect ( ( ) => getCardValue ( "11♥" ) ) . toThrow ( ) ;
33+ expect ( ( ) => getCardValue ( "1♥" ) ) . toThrow ( ) ;
34+ expect ( ( ) => getCardValue ( "Z♦" ) ) . toThrow ( ) ;
35+ } ) ;
36+
1237// Suggestion: Group the remaining test data into these categories:
1338// Number Cards (2-10)
1439// Face Cards (J, Q, K)
0 commit comments