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- } ) ;
9-
105// Case 2: Handle Number Cards (2-10):
11- test ( "should return a number matchig the rank value for given card " , ( ) => {
6+ test ( "should return a number matchig the rank value for number cards " , ( ) => {
127 const numberCard = getCardValue ( "5♠" ) ;
138 expect ( numberCard ) . toEqual ( 5 ) ;
149} ) ;
1510// Case 3: Handle Face Cards (J, Q, K):
1611test ( "should return 10 for Face Cards" , ( ) => {
17- const faceCard = getCardValue ( "K ♠" ) ;
12+ const faceCard = getCardValue ( "10 ♠" ) ;
1813 expect ( faceCard ) . toEqual ( 10 ) ;
1914} ) ;
2015// Case 4: Handle Ace (A):
@@ -23,7 +18,12 @@ test("should return 11 for Ace", () => {
2318 expect ( aceCard ) . toEqual ( 11 ) ;
2419} ) ;
2520// Case 5: Handle Invalid Cards:
26- test ( "should return 11 for Ace of Spades" , ( ) => {
27- const invalidCard = getCardValue ( "1♥" ) ;
21+ test ( "should return invalid card rank for cards that are not in the suite" , ( ) => {
22+ const invalidCard = getCardValue ( "100♥" ) ;
23+ expect ( invalidCard ) . toEqual ( "Invalid card rank." ) ;
24+ } ) ;
25+
26+ test ( "should return invalid card rank for cards that are not in the suite" , ( ) => {
27+ const invalidCard = getCardValue ( "3.1416♥" ) ;
2828 expect ( invalidCard ) . toEqual ( "Invalid card rank." ) ;
2929} ) ;
0 commit comments