@@ -19,72 +19,65 @@ test("Arbitrary non-card string", () => {
1919
2020// TODO: What other invalid card cases can you think of?
2121
22- test ( "Arbitrary non-card string '19♠' " , ( ) => {
22+ test ( "Card with number rank outside range 2-10 " , ( ) => {
2323 assert . throws (
2424 ( ) => getCardValue ( "19♠" ) ,
2525 / 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 " 1 9 ♠ " / ,
2626 "Expected clear error"
2727 ) ;
28+ assert . throws (
29+ ( ) => getCardValue ( "-3♦" ) ,
30+ / 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 " - 3 ♦ " / ,
31+ "Expected clear error"
32+ ) ;
2833} ) ;
2934
30- test ( "Arbitrary non-card string 'P♦' " , ( ) => {
35+ test ( "Card with letter rank other than the correct options " , ( ) => {
3136 assert . throws (
3237 ( ) => getCardValue ( "P♦" ) ,
3338 / 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 " P ♦ " / ,
3439 "Expected clear error"
3540 ) ;
36- } ) ;
37-
38- test ( "Arbitrary non-card string 's♦'" , ( ) => {
3941 assert . throws (
4042 ( ) => getCardValue ( "s♦" ) ,
4143 / 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 " s ♦ " / ,
4244 "Expected clear error"
4345 ) ;
44- } ) ;
45-
46- test ( "Arbitrary non-card string 'sOup♦'" , ( ) => {
4746 assert . throws (
48- ( ) => getCardValue ( "soUp♦ " ) ,
49- / 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 " s o U p ♦ " / ,
47+ ( ) => getCardValue ( "soUp♣ " ) ,
48+ / 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 " s o U p ♣ " / ,
5049 "Expected clear error"
5150 ) ;
5251} ) ;
5352
54- test ( "Arbitrary non-card string '-3♦' " , ( ) => {
53+ test ( "Card with valid number rank lacking suit " , ( ) => {
5554 assert . throws (
56- ( ) => getCardValue ( "-3♦ " ) ,
57- / 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 " - 3 ♦ " / ,
55+ ( ) => getCardValue ( "5 " ) ,
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 " 5 " / ,
5857 "Expected clear error"
5958 ) ;
6059} ) ;
6160
62- test ( "Arbitrary non-card string '5' " , ( ) => {
61+ test ( "Card with valid letter rank lacking suit " , ( ) => {
6362 assert . throws (
64- ( ) => getCardValue ( "5 " ) ,
65- / 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 " 5 " / ,
63+ ( ) => getCardValue ( "Q " ) ,
64+ / 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 " Q " / ,
6665 "Expected clear error"
6766 ) ;
6867} ) ;
6968
70- test ( "Arbitrary non-card string 'Q' " , ( ) => {
69+ test ( "Card with valid suit lacking rank " , ( ) => {
7170 assert . throws (
72- ( ) => getCardValue ( "Q " ) ,
73- / 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 " Q " / ,
71+ ( ) => getCardValue ( "♠ " ) ,
72+ / 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 " ♠ " / ,
7473 "Expected clear error"
7574 ) ;
7675} ) ;
7776
7877//Valid cases
7978
80- test ( "Valid card 'A♣' " , ( ) => {
79+ test ( "Valid cards " , ( ) => {
8180 assert . equal ( getCardValue ( "A♣" ) , 11 ) ;
82- } ) ;
83-
84- test ( "Valid card '10♣'" , ( ) => {
8581 assert . equal ( getCardValue ( "10♣" ) , 10 ) ;
86- } ) ;
87-
88- test ( "Valid card 'K♠'" , ( ) => {
8982 assert . equal ( getCardValue ( "K♠" ) , 10 ) ;
9083} ) ;
0 commit comments