@@ -10,7 +10,11 @@ test("Valid single-digit card", () => {
1010} ) ;
1111
1212test ( "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" ) ;
13+ assert . throws (
14+ ( ) => getCardValue ( "invalid" ) ,
15+ / 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 " / ,
16+ "Expected clear error"
17+ ) ;
1418} ) ;
1519
1620// TODO: What other invalid card cases can you think of?
@@ -30,19 +34,18 @@ test("Face cards return 10", () => {
3034 assert . equal ( getCardValue ( "K♥" ) , 10 ) ;
3135} ) ;
3236
33- test ( "Invalid rank throws an error" , ( ) => {
37+ test ( "Invalid format throws an error" , ( ) => {
38+ assert . throws ( ( ) => getCardValue ( "A★" ) , Error ) ;
3439 assert . throws ( ( ) => getCardValue ( "11♠" ) , Error ) ;
3540 assert . throws ( ( ) => getCardValue ( "X♥" ) , Error ) ;
36- } ) ;
37-
38- test ( "Invalid suit throws an error" , ( ) => {
39- assert . throws ( ( ) => getCardValue ( "A★" ) , Error ) ;
40- } ) ;
41-
42- test ( "Invalid format throws an error" , ( ) => {
4341 assert . throws ( ( ) => getCardValue ( "A" ) , Error ) ;
4442 assert . throws ( ( ) => getCardValue ( "♠A" ) , Error ) ;
4543 assert . throws ( ( ) => getCardValue ( " A♠" ) , Error ) ;
4644 assert . throws ( ( ) => getCardValue ( "A♠♠" ) , Error ) ;
45+ assert . throws ( ( ) => getCardValue ( undefined ) , Error ) ;
46+ assert . throws ( ( ) => getCardValue ( null ) , Error ) ;
47+ assert . throws ( ( ) => getCardValue ( "" ) , Error ) ;
48+ assert . throws ( ( ) => getCardValue ( "a♠" ) , Error ) ;
49+ assert . throws ( ( ) => getCardValue ( "k♥" ) , Error ) ;
50+ assert . throws ( ( ) => getCardValue ( "q♦" ) , Error ) ;
4751} ) ;
48-
0 commit comments