@@ -15,4 +15,64 @@ test(`Should return 11 when given an ace card`, () => {
1515// To learn how to test whether a function throws an error as expected in Jest,
1616// please refer to the Jest documentation:
1717// https://jestjs.io/docs/expect#tothrowerror
18+ // -----number cards------
19+ test ( `Should return 2 when given a 2 card` , ( ) => {
20+ expect ( getCardValue ( "2♥" ) ) . toEqual ( 2 ) ;
21+ } ) ;
1822
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 ) ;
46+ } ) ;
47+ // -----remaining face cards-----
48+ test ( `Should return 10 when given a jack card` , ( ) => {
49+ expect ( getCardValue ( "J♥" ) ) . toEqual ( 10 ) ;
50+ } ) ;
51+ test ( `Should return 10 when given a king card` , ( ) => {
52+ expect ( getCardValue ( "K♣" ) ) . toEqual ( 10 ) ;
53+ } ) ;
54+ test ( `Should return 10 when given a queen card` , ( ) => {
55+ expect ( getCardValue ( "Q♥" ) ) . toEqual ( 10 ) ;
56+ } ) ;
57+ // -----invalid cards-----
58+ test ( "Should throw an error for card without suit" , ( ) => {
59+ expect ( ( ) => getCardValue ( "A" ) ) . toThrow ( "Missing a specific suit symbol" ) ;
60+ } ) ;
61+
62+ test ( "Should throw an error for card with invalid number" , ( ) => {
63+ expect ( ( ) => getCardValue ( "0♥" ) ) . toThrow (
64+ "Missing a specific number and specific suit symbol"
65+ ) ;
66+ } ) ;
67+
68+ test ( "Should throw an error for empty input" , ( ) => {
69+ expect ( ( ) => getCardValue ( "" ) ) . toThrow (
70+ "Missing a specific number and specific suit symbol"
71+ ) ;
72+ } ) ;
73+
74+ test ( "Should throw an error for an invalid input" , ( ) => {
75+ expect ( ( ) => getCardValue ( "J♥♥" ) ) . toThrow (
76+ "Missing a specific number and specific suit symbol"
77+ ) ;
78+ } ) ;
0 commit comments