File tree Expand file tree Collapse file tree
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,16 +63,49 @@ function assertEquals(actualOutput, targetOutput) {
6363
6464// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
6565// Examples:
66- assertEquals ( getCardValue ( "9♠" ) , 9 ) ;
66+ assertEquals ( getCardValue ( "A♠" ) , 11 ) ;
67+ assertEquals ( getCardValue ( "Q♠" ) , 10 ) ;
68+ assertEquals ( getCardValue ( "6♠" ) , 6 ) ;
6769
6870// Handling invalid cards
6971try {
7072 getCardValue ( "invalid" ) ;
7173
72- // This line will not be reached if an error is thrown as expected
7374 console . error ( "Error was not thrown for invalid card 😢" ) ;
7475} catch ( e ) {
7576 console . log ( "Error thrown for invalid card 🎉" ) ;
7677}
7778
7879// What other invalid card cases can you think of?
80+
81+ try {
82+ getCardValue ( "11♠" ) ;
83+
84+ console . error ( "Error was not thrown for invalid card 😢" ) ;
85+ } catch ( e ) {
86+ console . log ( "Error thrown for invalid card 🎉" ) ;
87+ }
88+
89+ try {
90+ getCardValue ( "X♠" ) ;
91+
92+ console . error ( "Error was not thrown for invalid card 😢" ) ;
93+ } catch ( e ) {
94+ console . log ( "Error thrown for invalid card 🎉" ) ;
95+ }
96+
97+ try {
98+ getCardValue ( "AA" ) ;
99+
100+ console . error ( "Error was not thrown for invalid card 😢" ) ;
101+ } catch ( e ) {
102+ console . log ( "Error thrown for invalid card 🎉" ) ;
103+ }
104+
105+ try {
106+ getCardValue ( "9" ) ;
107+
108+ console . error ( "Error was not thrown for invalid card 😢" ) ;
109+ } catch ( e ) {
110+ console . log ( "Error thrown for invalid card 🎉" ) ;
111+ }
You can’t perform that action at this time.
0 commit comments