@@ -11,10 +11,34 @@ test(`Should return 11 when given an ace card`, () => {
1111
1212// Suggestion: Group the remaining test data into these categories:
1313// Number Cards (2-10)
14+
15+ test ( `Should return the correct value for number cards` , ( ) => {
16+ expect ( getCardValue ( "2♠" ) ) . toEqual ( 2 ) ;
17+ expect ( getCardValue ( "3♠" ) ) . toEqual ( 3 ) ;
18+ expect ( getCardValue ( "4♠" ) ) . toEqual ( 4 ) ;
19+ expect ( getCardValue ( "5♠" ) ) . toEqual ( 5 ) ;
20+ expect ( getCardValue ( "6♠" ) ) . toEqual ( 6 ) ;
21+ expect ( getCardValue ( "7♠" ) ) . toEqual ( 7 ) ;
22+ expect ( getCardValue ( "8♠" ) ) . toEqual ( 8 ) ;
23+ expect ( getCardValue ( "9♠" ) ) . toEqual ( 9 ) ;
24+ expect ( getCardValue ( "10♠" ) ) . toEqual ( 10 ) ;
25+ } ) ;
1426// Face Cards (J, Q, K)
27+ test ( `Should return 10 for face cards` , ( ) => {
28+ expect ( getCardValue ( "J♠" ) ) . toEqual ( 10 ) ;
29+ expect ( getCardValue ( "Q♠" ) ) . toEqual ( 10 ) ;
30+ expect ( getCardValue ( "K♠" ) ) . toEqual ( 10 ) ;
31+ } ) ;
1532// Invalid Cards
33+ test ( `Should throw an error for invalid cards` , ( ) => {
34+ expect ( ( ) => getCardValue ( "1♠" ) ) . toThrow ( ) ;
35+ expect ( ( ) => getCardValue ( "11♠" ) ) . toThrow ( ) ;
36+ expect ( ( ) => getCardValue ( "B♠" ) ) . toThrow ( ) ;
37+ expect ( ( ) => getCardValue ( "Z♠" ) ) . toThrow ( ) ;
38+ expect ( ( ) => getCardValue ( "A" ) ) . toThrow ( ) ;
39+ expect ( ( ) => getCardValue ( "10" ) ) . toThrow ( ) ;
40+ } ) ;
1641
1742// To learn how to test whether a function throws an error as expected in Jest,
1843// please refer to the Jest documentation:
1944// https://jestjs.io/docs/expect#tothrowerror
20-
0 commit comments