File tree Expand file tree Collapse file tree 1 file changed +7
-16
lines changed
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Original file line number Diff line number Diff line change 2222// execute the code to ensure all tests pass.
2323
2424function getCardValue ( card ) {
25-
26- }
27-
25+ // TODO: Implement this function
26+ }
2827
2928// The line below allows us to load the getCardValue function into tests in other files.
3029// This will be useful in the "rewrite tests with jest" step.
@@ -39,23 +38,15 @@ function assertEquals(actualOutput, targetOutput) {
3938}
4039
4140// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
42- // Examples 1 numbers :
41+ // Examples:
4342assertEquals ( getCardValue ( "9♠" ) , 9 ) ;
4443
45-
46- function assertThrow ( fn ) {
47- try { ( fn )
48- // we try to run this function, if it throws, stop running this bit and run the catch below
44+ // Handling invalid cards
45+ try {
46+ getCardValue ( "invalid" ) ;
4947
5048 // This line will not be reached if an error is thrown as expected
5149 console . error ( "Error was not thrown for invalid card" ) ;
52- } catch ( error ) {
53- // if the above code throws, we catch the error here, that stops the whole program crashing
54-
55-
50+ } catch ( e ) { }
5651
5752// What other invalid card cases can you think of?
58-
59- //Examples wrong type:
60- assertThrow ( ( ) => getCardValue ( "null" ) )
61- assertThrow ( ( ) => getCardValue ( "42" ) )
You can’t perform that action at this time.
0 commit comments