File tree Expand file tree Collapse file tree
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,29 @@ test(`Should return 11 when given an ace card`, () => {
99 expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
1010} ) ;
1111
12+ // Case 2: Number cards (2-10)
13+ test ( `Should return the correct number for number cards` , ( ) => {
14+ expect ( getCardValue ( "2♠" ) ) . toEqual ( 2 ) ;
15+ expect ( getCardValue ( "5♥" ) ) . toEqual ( 5 ) ;
16+ expect ( getCardValue ( "10♦" ) ) . toEqual ( 10 ) ;
17+ } ) ;
18+
19+ // Case 3: Face cards (J, Q, K)
20+ test ( `Should return 10 for face cards` , ( ) => {
21+ expect ( getCardValue ( "J♣" ) ) . toEqual ( 10 ) ;
22+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
23+ expect ( getCardValue ( "K♥" ) ) . toEqual ( 10 ) ;
24+ } ) ;
25+
26+ // Case 4: Invalid cards
27+ test ( `Should throw error for invalid cards` , ( ) => {
28+ expect ( ( ) => getCardValue ( "1♠" ) ) . toThrow ( "Invalid card" ) ; // invalid rank
29+ expect ( ( ) => getCardValue ( "A?" ) ) . toThrow ( "Invalid card" ) ; // invalid suit
30+ expect ( ( ) => getCardValue ( "10♠♠" ) ) . toThrow ( "Invalid card" ) ; // extra character
31+ expect ( ( ) => getCardValue ( "" ) ) . toThrow ( "Invalid card" ) ; // empty string
32+ expect ( ( ) => getCardValue ( "banana" ) ) . toThrow ( "Invalid card" ) ; // completely invalid
33+ } ) ;
34+
1235// Suggestion: Group the remaining test data into these categories:
1336// Number Cards (2-10)
1437// Face Cards (J, Q, K)
You can’t perform that action at this time.
0 commit comments