@@ -8,31 +8,35 @@ const getCardValue = require("../implement/3-get-card-value");
88test ( `Should return 11 when given an ace card` , ( ) => {
99 expect ( getCardValue ( "A♠" ) ) . toEqual ( 11 ) ;
1010} ) ;
11- test ( `should return 9 when given a 9♠ card` , ( ) => {
12- expect ( getCardValue ( "9♠" ) ) . toEqual ( 9 ) ;
13- } ) ;
14- test ( `should return 10 when given a face card K♦` , ( ) => {
15- expect ( getCardValue ( "K♦" ) ) . toEqual ( 10 ) ;
11+ // Number Cards (2-10)
12+ test ( "should return the value of number cards (2–10)" , ( ) => {
13+ expect ( getCardValue ( "2♣" ) ) . toEqual ( 2 ) ;
14+ expect ( getCardValue ( "5♦" ) ) . toEqual ( 5 ) ;
15+ expect ( getCardValue ( "9♥" ) ) . toEqual ( 9 ) ;
16+ expect ( getCardValue ( "10♠" ) ) . toEqual ( 10 ) ;
1617} ) ;
17- test ( `should return 10 when given a 10` , ( ) => {
18- expect ( getCardValue ( "10♥" ) ) . toEqual ( 10 ) ;
18+ // Face Cards (J, Q, K)
19+ test ( "should return 10 for face cards" , ( ) => {
20+ expect ( getCardValue ( "J♣" ) ) . toEqual ( 10 ) ;
21+ expect ( getCardValue ( "Q♦" ) ) . toEqual ( 10 ) ;
22+ expect ( getCardValue ( "K♥" ) ) . toEqual ( 10 ) ;
1923} ) ;
20- test ( `should throw error for invalid Ranks` , ( ) => {
24+ // Invalid Cards
25+ test ( "should throw error for invalid ranks" , ( ) => {
2126 expect ( ( ) => getCardValue ( "11♠" ) ) . toThrow ( ) ;
2227} ) ;
23- test ( `should throw error for invalid Suits` , ( ) => {
28+
29+ test ( "should throw error for invalid suits" , ( ) => {
2430 expect ( ( ) => getCardValue ( "A?" ) ) . toThrow ( ) ;
2531} ) ;
26- test ( `should throw error for missing Suits` , ( ) => {
32+
33+ test ( "should throw error for missing suits" , ( ) => {
2734 expect ( ( ) => getCardValue ( "A" ) ) . toThrow ( ) ;
2835} ) ;
29- test ( `should throw error for non String input` , ( ) => {
30- expect ( ( ) => getCardValue ( "10" ) ) . toThrow ( ) ;
36+
37+ test ( "should throw error for non-string input" , ( ) => {
38+ expect ( ( ) => getCardValue ( 10 ) ) . toThrow ( ) ;
3139} ) ;
32- // Suggestion: Group the remaining test data into these categories:
33- // Number Cards (2-10)
34- // Face Cards (J, Q, K)
35- // Invalid Cards
3640
3741// To learn how to test whether a function throws an error as expected in Jest,
3842// please refer to the Jest documentation:
0 commit comments