@@ -9,8 +9,48 @@ test("Valid single-digit card", () => {
99 assert . equal ( getCardValue ( "9♠" ) , 9 ) ;
1010} ) ;
1111
12+ test ( "Valid single-digit card" , ( ) => {
13+ assert . equal ( getCardValue ( "A♠" ) , 11 ) ;
14+ } ) ;
15+
16+ test ( "Valid single-digit card" , ( ) => {
17+ assert . equal ( getCardValue ( "7♦" ) , 7 ) ;
18+ } ) ;
19+
20+ test ( "Valid Valid numeric vale" , ( ) => {
21+ assert . equal ( getCardValue ( "J♣" ) , 10 ) ;
22+ } ) ;
23+
24+ test ( "Valid numeric vale" , ( ) => {
25+ assert . equal ( getCardValue ( "K♣" ) , 10 ) ;
26+ } ) ;
27+
28+ test ( "Valid numeric vale" , ( ) => {
29+ assert . equal ( getCardValue ( "Q♦" ) , 10 ) ;
30+ } ) ;
31+
1232test ( "Arbitrary non-card string" , ( ) => {
13- assert . throws ( ( ) => getCardValue ( "invalid" ) , / E x p e c t e d a n u m b e r f o l l o w e d b y a s u i t , b u t g o t " i n v a l i d " / , "Expected clear error" ) ;
33+ assert . throws (
34+ ( ) => getCardValue ( "Invalid" ) ,
35+ / T h e c a r d y o u e n t e r e d i s i n v a l i d \. P l e a s e e n t e r a v a l i d c a r d \. / ,
36+ "Expected a clear error for an invalid card"
37+ ) ;
1438} ) ;
1539
1640// TODO: What other invalid card cases can you think of?
41+
42+ test ( "Invalid string" , ( ) => {
43+ assert . throws ( ( ) => getCardValue ( "11♠" ) , / T h e c a r d y o u e n t e r e d i s i n v a l i d / ) ;
44+ } ) ;
45+
46+ test ( "Invalid string" , ( ) => {
47+ assert . throws ( ( ) => getCardValue ( "1♥" ) , / T h e c a r d y o u e n t e r e d i s i n v a l i d / ) ;
48+ } ) ;
49+
50+ test ( "Invalid string" , ( ) => {
51+ assert . throws ( ( ) => getCardValue ( "JX" ) , / T h e c a r d y o u e n t e r e d i s i n v a l i d / ) ;
52+ } ) ;
53+
54+ test ( "Invalid string" , ( ) => {
55+ assert . throws ( ( ) => getCardValue ( "♠A" ) , / T h e c a r d y o u e n t e r e d i s i n v a l i d / ) ;
56+ } ) ;
0 commit comments