@@ -7,6 +7,38 @@ const getCardValue = require("../implement/3-get-card-value");
77// Case 1: Ace (A)
88test ( `Should return 11 when given an ace card` , ( ) => {
99 expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
10+ expect ( getCardValue ( "A♦" ) ) . toEqual ( 11 ) ;
11+ expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
12+ } ) ;
13+
14+ // Case 2: Face cards Jack, Queen, King (J,Q,K)
15+ test ( `Should return 10 when given a face card` , ( ) => {
16+ expect ( getCardValue ( "J♠" ) ) . toEqual ( 10 ) ;
17+ expect ( getCardValue ( "J♦" ) ) . toEqual ( 10 ) ;
18+ expect ( getCardValue ( "Q♣" ) ) . toEqual ( 10 ) ;
19+ expect ( getCardValue ( "K♥" ) ) . toEqual ( 10 ) ;
20+ } ) ;
21+
22+ // Case 3: Number cards 2-10 (2,3,4,5,6,7,8,9)
23+ test ( `Should return the card value when given a number card` , ( ) => {
24+ expect ( getCardValue ( "2♠" ) ) . toEqual ( 2 ) ;
25+ expect ( getCardValue ( "3♦" ) ) . toEqual ( 3 ) ;
26+ expect ( getCardValue ( "4♣" ) ) . toEqual ( 4 ) ;
27+ expect ( getCardValue ( "5♥" ) ) . toEqual ( 5 ) ;
28+ expect ( getCardValue ( "6♠" ) ) . toEqual ( 6 ) ;
29+ expect ( getCardValue ( "7♦" ) ) . toEqual ( 7 ) ;
30+ expect ( getCardValue ( "8♣" ) ) . toEqual ( 8 ) ;
31+ expect ( getCardValue ( "9♥" ) ) . toEqual ( 9 ) ;
32+ } ) ;
33+
34+ // Case 4: Invalid card
35+ test ( `Should return 10 when given an ace card` , ( ) => {
36+ expect ( getCardValue ( "invalid" ) ) . toEqual ( "invalid" ) ;
37+ expect ( getCardValue ( "♦" ) ) . toEqual ( "invalid" ) ;
38+ expect ( getCardValue ( "4" ) ) . toEqual ( "invalid" ) ;
39+ expect ( getCardValue ( "" ) ) . toEqual ( "invalid" ) ;
40+ expect ( getCardValue ( "m" ) ) . toEqual ( "invalid" ) ;
41+ expect ( getCardValue ( "300" ) ) . toEqual ( "invalid" ) ;
1042} ) ;
1143
1244// Suggestion: Group the remaining test data into these categories:
0 commit comments