@@ -9,24 +9,31 @@ test("should return 11 for Ace of Spades", () => {
99
1010// Case 2: Handle Number Cards (2-10):
1111test ( "should return the number entered as input" , ( ) => {
12- const numberCards = getCardValue ( "4♠" ) ;
13- expect ( numberCards ) . toEqual ( 4 ) ;
12+ for ( let i = 2 ; i <= 10 ; i ++ ) {
13+ expect ( getCardValue ( `${ i } ♠` ) ) . toEqual ( i ) ;
14+ }
1415} ) ;
1516
1617// Case 3: Handle Face Cards (J, Q, K):
1718test ( "should return 10 for face cards J Q K" , ( ) => {
18- const faceCards = getCardValue ( "Q♠" ) ;
19- expect ( faceCards ) . toEqual ( 10 ) ;
19+ expect ( getCardValue ( "Q♠" ) ) . toEqual ( 10 ) ;
20+ expect ( getCardValue ( "J♠" ) ) . toEqual ( 10 ) ;
21+ expect ( getCardValue ( "K♠" ) ) . toEqual ( 10 ) ;
2022} ) ;
2123
2224// Case 4: Handle Ace (A):
23- test ( "should return 11 after entering Ace A" , ( ) => {
24- const handleAce = getCardValue ( "A♠" ) ;
25- expect ( handleAce ) . toEqual ( 11 ) ;
25+ test ( "should return 11 when entering Ace A" , ( ) => {
26+ expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
27+ expect ( getCardValue ( "A♥" ) ) . toEqual ( 11 ) ;
28+ expect ( getCardValue ( "A♦" ) ) . toEqual ( 11 ) ;
29+ expect ( getCardValue ( "A♣" ) ) . toEqual ( 11 ) ;
2630} ) ;
2731
2832// Case 5: Handle Invalid Cards:
2933test ( `should return string ("Invalid card rank.") for invalid inputs` , ( ) => {
30- const invalidCards = getCardValue ( "HelloWorld!" ) ;
31- expect ( invalidCards ) . toEqual ( "Invalid card rank." ) ;
34+ expect ( getCardValue ( "HelloWorld!" ) ) . toEqual ( "Invalid card rank." ) ;
35+ expect ( getCardValue ( "♠" ) ) . toEqual ( "Invalid card rank." ) ;
36+ expect ( getCardValue ( "979" ) ) . toEqual ( "Invalid card rank." ) ;
37+ expect ( getCardValue ( "1" ) ) . toEqual ( "Invalid card rank." ) ;
38+ expect ( getCardValue ( [ 1 , 2 , 3 ] ) ) . toEqual ( "Invalid card rank." ) ;
3239} ) ;
0 commit comments