22// We will use the same function, but write tests for it using Jest in this file.
33const getCardValue = require ( "../implement/3-get-card-value" ) ;
44
5- test ( "should return 11 for Ace of Spades" , ( ) => {
6- const aceOfSpades = getCardValue ( "A♠" ) ;
7- expect ( aceOfSpades ) . toEqual ( 11 ) ;
8- } ) ;
5+
96
107// Case 2: Handle Number Cards (2-10):
8+ test ( "should return 5 for five of spades " , ( ) => {
9+ const fiveOfSpades = getCardValue ( "5♠" ) ;
10+ expect ( fiveOfSpades ) . toEqual ( 5 )
11+ } )
1112// Case 3: Handle Face Cards (J, Q, K):
13+ test ( "should return 10 for king of spades" , ( ) => {
14+ const kingOfSpades = getCardValue ( "K♠" ) ;
15+ expect ( kingOfSpades ) . toEqual ( 10 )
16+ } )
1217// Case 4: Handle Ace (A):
18+ test ( "should return 11 for Ace of Spades" , ( ) => {
19+ const aceOfSpades = getCardValue ( "A♠" ) ;
20+ expect ( aceOfSpades ) . toEqual ( 11 ) ;
21+ } ) ;
1322// Case 5: Handle Invalid Cards:
23+ test ( "should through error for 1 of spades" , ( ) => {
24+ expect ( ( ) => getCardValue ( "1♠" ) ) . toThrow ( 'Invalid card rank: 1' )
25+ } )
26+
27+
28+ test ( "should throw error for five*" , ( ) => {
29+ expect ( ( ) => getCardValue ( "5*" ) ) . toThrow ( "Invalid card face: *" ) ;
30+ } )
0 commit comments