@@ -11,38 +11,22 @@ test(`Should return 11 when given an ace card`, () => {
1111// Number Cards (2-10)
1212// Face Cards (J, Q, K)
1313// Invalid Cards
14-
1514// To learn how to test whether a function throws an error as expected in Jest,
1615// please refer to the Jest documentation:
1716// https://jestjs.io/docs/expect#tothrowerror
1817// -----number cards------
19- test ( `Should return 2 when given a 2 card` , ( ) => {
20- expect ( getCardValue ( "2♥" ) ) . toEqual ( 2 ) ;
21- } ) ;
22-
23- test ( `Should return 3 when given a 3 card` , ( ) => {
24- expect ( getCardValue ( "3♣" ) ) . toEqual ( 3 ) ;
25- } ) ;
26- test ( `Should return 4 when given a 4 card` , ( ) => {
27- expect ( getCardValue ( "4♦" ) ) . toEqual ( 4 ) ;
28- } ) ;
29- test ( `Should return 5 when given a 5 card` , ( ) => {
30- expect ( getCardValue ( "5♠" ) ) . toEqual ( 5 ) ;
31- } ) ;
32- test ( `Should return 6 when given a 6 card` , ( ) => {
33- expect ( getCardValue ( "6♦" ) ) . toEqual ( 6 ) ;
34- } ) ;
35- test ( `Should return 7 when given a 7 card` , ( ) => {
36- expect ( getCardValue ( "7♥" ) ) . toEqual ( 7 ) ;
37- } ) ;
38- test ( `Should return 8 when given a 8 card` , ( ) => {
39- expect ( getCardValue ( "8♠" ) ) . toEqual ( 8 ) ;
40- } ) ;
41- test ( `Should return 9 when given a 9 card` , ( ) => {
42- expect ( getCardValue ( "9♥" ) ) . toEqual ( 9 ) ;
43- } ) ;
44- test ( `Should return 10 when given a 10 card` , ( ) => {
45- expect ( getCardValue ( "10♣" ) ) . toEqual ( 10 ) ;
18+ test . each ( [
19+ { card : "2♥" , value : 2 } ,
20+ { card : "3♣" , value : 3 } ,
21+ { card : "4♦" , value : 4 } ,
22+ { card : "5♠" , value : 5 } ,
23+ { card : "6♦" , value : 6 } ,
24+ { card : "7♥" , value : 7 } ,
25+ { card : "8♠" , value : 8 } ,
26+ { card : "9♥" , value : 9 } ,
27+ { card : "10♣" , value : 10 } ,
28+ ] ) ( "Should return $value when given a $card card" , ( { card, value } ) => {
29+ expect ( getCardValue ( card ) ) . toEqual ( value ) ;
4630} ) ;
4731// -----remaining face cards-----
4832test ( `Should return 10 when given a jack card` , ( ) => {
0 commit comments