@@ -7,10 +7,55 @@ import { getCardValue } from "../implement/3-get-card-value.js";
77
88test ( "Valid single-digit card" , ( ) => {
99 assert . equal ( getCardValue ( "9♠" ) , 9 ) ;
10+ assert . equal ( getCardValue ( "10♠" ) , 10 ) ;
11+ } ) ;
12+
13+ test ( "Ace card" , ( ) => {
14+ assert . equal ( getCardValue ( "A♠" ) , 11 ) ;
15+ assert . equal ( getCardValue ( "A♣" ) , 11 ) ;
16+ assert . equal ( getCardValue ( "A♦" ) , 11 ) ;
17+ } ) ;
18+
19+ test ( "Face card" , ( ) => {
20+ assert . equal ( getCardValue ( "J♠" ) , 10 ) ;
1021} ) ;
1122
1223test ( "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" ) ;
24+ assert . throws (
25+ ( ) => getCardValue ( "invalid" ) ,
26+ / 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 / ,
27+ "Expected clear error"
28+ ) ;
29+
30+ assert . throws (
31+ ( ) => getCardValue ( "1♠" ) ,
32+ / 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 / ,
33+ "Expected clear error"
34+ ) ;
35+
36+ assert . throws (
37+ ( ) => getCardValue ( "9X" ) ,
38+ / 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 / ,
39+ "Expected clear error"
40+ ) ;
41+
42+ assert . throws (
43+ ( ) => getCardValue ( "11♠" ) ,
44+ / 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 / ,
45+ "Expected clear error"
46+ ) ;
47+
48+ assert . throws (
49+ ( ) => getCardValue ( "7" ) ,
50+ / 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 / ,
51+ "Expected clear error"
52+ ) ;
53+
54+ assert . throws (
55+ ( ) => getCardValue ( "" ) ,
56+ / 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 / ,
57+ "Expected clear error"
58+ ) ;
1459} ) ;
1560
1661// TODO: What other invalid card cases can you think of?
0 commit comments