@@ -7,14 +7,41 @@ 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+ expect ( getCardValue ( "A♣" ) ) . toEqual ( 11 ) ;
1013} ) ;
1114
12- // Suggestion: Group the remaining test data into these categories:
13- // Number Cards (2-10)
14- // Face Cards (J, Q, K)
15- // Invalid Cards
15+ // Number Cards (2-10)
16+ test ( `Should return the numeric value for number cards` , ( ) => {
17+ expect ( getCardValue ( "2♠" ) ) . toEqual ( 2 ) ;
18+ expect ( getCardValue ( "3♥" ) ) . toEqual ( 3 ) ;
19+ expect ( getCardValue ( "4♦" ) ) . toEqual ( 4 ) ;
20+ expect ( getCardValue ( "5♣" ) ) . toEqual ( 5 ) ;
21+ expect ( getCardValue ( "6♠" ) ) . toEqual ( 6 ) ;
22+ expect ( getCardValue ( "7♥" ) ) . toEqual ( 7 ) ;
23+ expect ( getCardValue ( "8♦" ) ) . toEqual ( 8 ) ;
24+ expect ( getCardValue ( "9♣" ) ) . toEqual ( 9 ) ;
25+ expect ( getCardValue ( "10♠" ) ) . toEqual ( 10 ) ;
26+ } ) ;
27+
28+ // Face Cards (J, Q, K)
29+ test ( `Should return 10 for face cards` , ( ) => {
30+ expect ( getCardValue ( "J♥" ) ) . toEqual ( 10 ) ;
31+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
32+ expect ( getCardValue ( "K♣" ) ) . toEqual ( 10 ) ;
33+ expect ( getCardValue ( "J♠" ) ) . toEqual ( 10 ) ;
34+ expect ( getCardValue ( "Q♥" ) ) . toEqual ( 10 ) ;
35+ expect ( getCardValue ( "K♦" ) ) . toEqual ( 10 ) ;
36+ } ) ;
1637
17- // To learn how to test whether a function throws an error as expected in Jest,
18- // please refer to the Jest documentation:
19- // https://jestjs.io/docs/expect#tothrowerror
38+ // Invalid Cards
39+ test ( `Should throw an error for invalid cards` , ( ) => {
40+ expect ( ( ) => getCardValue ( "invalid" ) ) . toThrow ( ) ;
41+ expect ( ( ) => getCardValue ( "1♠" ) ) . toThrow ( ) ;
42+ expect ( ( ) => getCardValue ( "A♤" ) ) . toThrow ( ) ;
43+ expect ( ( ) => getCardValue ( "A" ) ) . toThrow ( ) ;
44+ expect ( ( ) => getCardValue ( "" ) ) . toThrow ( ) ;
45+ expect ( ( ) => getCardValue ( 123 ) ) . toThrow ( ) ;
46+ } ) ;
2047
0 commit comments