Repository navigation
Conversation
|
Just need to fix |
| try { | ||
| expect(describeMedian([])).toBe( | ||
| "Could not calculate a median: calculateMedian requires a non-empty array" | ||
| ); | ||
| } catch (error) { | ||
| throw new Error(`Empty-array case failed: ${error.message}`); | ||
| } |
There was a problem hiding this comment.
The try-catch block here is not needed as describeMedian() has already catched the error and no longer throws more error. If you need further clarification, please discuss with a volunteer on Saturday workshop. Thank you.
| try { | ||
| expect(describeMedian(["banana", "apple", "orange"])).toBe( | ||
| "Could not calculate a median: calculateMedian requires an array of numbers" | ||
| ); | ||
| } catch (error) { | ||
| throw new Error(`String-array case failed: ${error.message}`); | ||
| } |
There was a problem hiding this comment.
The try-catch block here is not needed as describeMedian() has already catched the error and no longer throws more error. If you need further clarification, please discuss with a volunteer on Saturday workshop. Thank you.
| // Given no argument at all | ||
| // When passed to calculateMean | ||
| // Then it should throw Error("calculateMean requires an array of numbers") | ||
| it("throws when the input has no argument", () => { | ||
| expect(() => calculateMean("")).toThrow( | ||
| "calculateMean requires an array of numbers" | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Empty string is still an argument, but this test case should be not passing in any argument. Please fix it, thank you.
Task code
CYF-1071
Changelist
Fixed code in the respective files