@@ -18,3 +18,40 @@ test(`Should return 11 when given an ace card`, () => {
1818// please refer to the Jest documentation:
1919// https://jestjs.io/docs/expect#tothrowerror
2020
21+ //
22+
23+ // This statement loads the getCardValue function
24+ const getCardValue = require ( "../implement/3-get-card-value" ) ;
25+
26+ // Case 1: Ace (A)
27+ test ( `Should return 11 when given an ace card` , ( ) => {
28+ expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
29+ expect ( getCardValue ( "A♥" ) ) . toEqual ( 11 ) ;
30+ } ) ;
31+
32+ // Case 2: Number Cards (2–10)
33+ test ( `Should return the numeric value for number cards` , ( ) => {
34+ expect ( getCardValue ( "2♦" ) ) . toEqual ( 2 ) ;
35+ expect ( getCardValue ( "5♣" ) ) . toEqual ( 5 ) ;
36+ expect ( getCardValue ( "10♥" ) ) . toEqual ( 10 ) ;
37+ } ) ;
38+
39+ // Case 3: Face Cards (J, Q, K)
40+ test ( `Should return 10 for face cards` , ( ) => {
41+ expect ( getCardValue ( "J♠" ) ) . toEqual ( 10 ) ;
42+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
43+ expect ( getCardValue ( "K♣" ) ) . toEqual ( 10 ) ;
44+ } ) ;
45+
46+ // Case 4: Invalid Cards
47+ test ( `Should throw error for invalid cards` , ( ) => {
48+ expect ( ( ) => getCardValue ( "invalid" ) ) . toThrow ( ) ;
49+
50+ expect ( ( ) => getCardValue ( "1♠" ) ) . toThrow ( ) ;
51+
52+ expect ( ( ) => getCardValue ( "11♥" ) ) . toThrow ( ) ;
53+
54+ expect ( ( ) => getCardValue ( "AX" ) ) . toThrow ( ) ;
55+
56+ expect ( ( ) => getCardValue ( "" ) ) . toThrow ( ) ;
57+ } ) ;
0 commit comments