Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Implement and rewrite test#1130
Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Implement and rewrite test#1130Pretty548 wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
Please note that in CYF courses, the recommended way to inform the reviewer of your changes is to do both of the following:
- Reply to their feedback.
- In the responses, clarify how each piece of feedback was addressed to demonstrate that you've carefully reviewed the suggestions.
- You may find the suggestions in this PR Guide useful.
- Your response may trigger a notification (depending on the reviewer's settings), helping ensure they’re aware of the updates you’ve made.
- In the responses, clarify how each piece of feedback was addressed to demonstrate that you've carefully reviewed the suggestions.
- Replace the "Reviewed" label by a "Needs review" label (which you have done -- great!)
- Without this label, the reviewer would not know if your changes is ready to be reviewed.
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
Show resolved
Hide resolved
| test("should return false when numerator is negative", () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| test("should return true when both numerator and denominator are negative and numerator is smaller than denominator", () => { | ||
| expect(isProperFraction(-1, -2)).toEqual(true); | ||
| }); |
There was a problem hiding this comment.
The test description on line 28 is not quite accurate.
For proper fractions, the condition is, "the absolute value of denominator is larger than the absolute value of the numerator". So we can create a category for proper fractions and describe it as:
should return true when abs(numerator) < abs(denominator)
and then test all combinations of positive/negative numerator and denominator (for proper fraction) in this category.
There was a problem hiding this comment.
Thank you for the feedback. I’ve updated the tests to follow the rule that a proper fraction is when abs(numerator) < abs(denominator). I grouped the proper fraction cases together and included the different positive and negative combinations. Please let me know if there is anything else I should improve.
| test(`should return "Invalid angle" when angle is not a number`, () => { | ||
| expect(getAngleType("not a number")).toEqual("Invalid angle"); | ||
| }); |
There was a problem hiding this comment.
What do you expect from this function call:
getAngleType("100") or getAngleType(" +1e2") ?
Note: You don't have to include this test because the spec has already stated you can assume the parameters are always valid numbers.
There was a problem hiding this comment.
Thanks for the clarification! I did not include tests for non-number inputs since the spec assumes valid numbers.
| }); | ||
|
|
||
| // Proper fractions | ||
| test("should return true when abs(numerator) < abs(denominator)", () => { |
There was a problem hiding this comment.
You could also apply this notation to improper fractions.
There was a problem hiding this comment.
Thanks for the suggestion! I updated the improper fraction test description to use the same abs notation and added a negative numerator/denominator case.
- Added tests for proper fractions using abs(numerator) < abs(denominator) - Added tests for improper fractions using abs(numerator) >= abs(denominator) - Covered positive, negative, and zero cases - Added test for denominator equal to zero
|
All good now. Well done. |
Learners, PR Template
Self checklist
Changelist
This PR implements the required functions and rewrites the existing tests for Sprint 3 in the
1-implement-and-rewrite-testsdirectory.All tests were updated to correctly reflect the expected behaviour, and the implementations were written to make the tests pass.