@@ -9,6 +9,56 @@ test(`Should return 11 when given an ace card`, () => {
99 expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
1010} ) ;
1111
12+ // Number cards
13+ test ( "Should return 2 for 2♣" , ( ) => {
14+ expect ( getCardValue ( "2♣" ) ) . toEqual ( 2 ) ;
15+ } ) ;
16+
17+ test ( "Should return 10 for 10♥" , ( ) => {
18+ expect ( getCardValue ( "10♥" ) ) . toEqual ( 10 ) ;
19+ } ) ;
20+
21+ // Face cards
22+ test ( "Should return 10 for J♦" , ( ) => {
23+ expect ( getCardValue ( "J♦" ) ) . toEqual ( 10 ) ;
24+ } ) ;
25+
26+ test ( "Should return 10 for Q♠" , ( ) => {
27+ expect ( getCardValue ( "Q♠" ) ) . toEqual ( 10 ) ;
28+ } ) ;
29+
30+ test ( "Should return 10 for K♣" , ( ) => {
31+ expect ( getCardValue ( "K♣" ) ) . toEqual ( 10 ) ;
32+ } ) ;
33+
34+ // =========================================================
35+ // INVALID CARDS
36+ // =========================================================
37+
38+ test ( "Should throw an error for 1♠" , ( ) => {
39+ expect ( ( ) => getCardValue ( "1♠" ) ) . toThrowError ( ) ;
40+ } ) ;
41+
42+ test ( "Should throw an error for A?" , ( ) => {
43+ expect ( ( ) => getCardValue ( "A?" ) ) . toThrowError ( ) ;
44+ } ) ;
45+
46+ test ( "Should throw an error for empty string" , ( ) => {
47+ expect ( ( ) => getCardValue ( "" ) ) . toThrowError ( ) ;
48+ } ) ;
49+
50+ test ( "Should throw an error for 11♣" , ( ) => {
51+ expect ( ( ) => getCardValue ( "11♣" ) ) . toThrowError ( ) ;
52+ } ) ;
53+
54+ test ( "Should throw an error for invalid rank" , ( ) => {
55+ expect ( ( ) => getCardValue ( "Z♦" ) ) . toThrowError ( ) ;
56+ } ) ;
57+
58+ test ( "Should throw an error for missing rank" , ( ) => {
59+ expect ( ( ) => getCardValue ( "♠" ) ) . toThrowError ( ) ;
60+ } ) ;
61+
1262// Suggestion: Group the remaining test data into these categories:
1363// Number Cards (2-10)
1464// Face Cards (J, Q, K)
0 commit comments