Skip to content

Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Implement and rewrite test#1130

Open
Pretty548 wants to merge 12 commits intoCodeYourFuture:mainfrom
Pretty548:coursework/sprint-3-implement-and-rewrite
Open

Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Implement and rewrite test#1130
Pretty548 wants to merge 12 commits intoCodeYourFuture:mainfrom
Pretty548:coursework/sprint-3-implement-and-rewrite

Conversation

@Pretty548
Copy link

@Pretty548 Pretty548 commented Mar 2, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

This PR implements the required functions and rewrites the existing tests for Sprint 3 in the 1-implement-and-rewrite-tests directory.

All tests were updated to correctly reflect the expected behaviour, and the implementations were written to make the tests pass.

@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 2, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function implementation looks good.

This exercise has a second part "2 Rewrite tests with Jest".

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 11, 2026
@Pretty548 Pretty548 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 15, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@github-actions

This comment has been minimized.

@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
  • 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.

Comment on lines +28 to +34
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);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 15, 2026
@Pretty548 Pretty548 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 15, 2026
Comment on lines +45 to +47
test(`should return "Invalid angle" when angle is not a number`, () => {
expect(getAngleType("not a number")).toEqual("Invalid angle");
});
Copy link
Contributor

@cjyuan cjyuan Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also apply this notation to improper fractions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I updated the improper fraction test description to use the same abs notation and added a negative numerator/denominator case.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 15, 2026
- 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
@Pretty548 Pretty548 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 15, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Mar 15, 2026

All good now. Well done.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants