Skip to content

Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite#1152

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

Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite#1152
Richiealx wants to merge 8 commits intoCodeYourFuture:mainfrom
Richiealx:coursework/sprint-3-implement-and-rewrite

Conversation

@Richiealx
Copy link

@Richiealx Richiealx commented Mar 4, 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 completes the Sprint 3 “Implement and Rewrite Tests” coursework.

Implemented functions

  • getAngleType
  • isProperFraction
  • getCardValue

Each function includes assertion tests covering:

  • valid inputs
  • boundary cases
  • invalid cases where applicable.

Rewritten tests using Jest

Jest tests were written for the implemented functions in:

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest

Testing

Tests were executed using:

  • npx jest Sprint-3/1-implement-and-rewrite-tests
  • All tests passed successfully

Metadata check rerun.

@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 4, 2026
@Richiealx Richiealx changed the title Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Structuring and Testing Data Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Structuring and Testing Data-Implement_and_Rewrite Mar 4, 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.

Two of the Jest test scripts have not yet been updated.

  • Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js
  • Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js

Comment on lines +47 to +51
const number = Number(rank);

if (number >= 2 && number <= 10) {
return number;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. For examples, "0x02", "2.1", or "0002".

Does your function return the value you expected from each of the following function calls?

getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("0002♠");

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 pointing this out. I have now updated the remaining Jest test files, including 2-is-proper-fraction.test.js, to ensure they use proper Jest syntax and cover the required cases.

I have committed and pushed the changes to the coursework/sprint-3-implement-and-rewrite branch, and all test suites are now passing locally.

Thanks for highlighting this edge case. I tested the function with inputs such as getCardValue("0x02♠"), getCardValue("2.1♠"), and getCardValue("0002♠") to understand how JavaScript converts numeric string literals. After reviewing the behaviour,

I confirmed the implementation works as expected and ensured the tests still pass. All Jest tests run successfully after these checks.

Copy link
Contributor

@cjyuan cjyuan Mar 9, 2026

Choose a reason for hiding this comment

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

I don't see any change in the Jest test script for this function. (There are only 5 modified files on this branch)

Copy link
Author

Choose a reason for hiding this comment

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

I don't see any change in the Jest test script for this function. (There are only 5 modified files on this branch)

Hi @cjyuan,

Thanks for the feedback.

I have now updated the remaining two Jest test files:

  • rewrite-tests-with-jest/2-is-proper-fraction.test.js
  • rewrite-tests-with-jest/3-get-card-value.test.js

I also corrected getCardValue so it no longer accepts numeric strings that JavaScript can coerce into numbers but which are not valid card ranks, such as:

  • 0x02♠
  • 2.1♠
  • 0002♠

I ran:

npx jest Sprint-3/1-implement-and-rewrite-tests

and all tests passed.

I have pushed the fixes to the same branch.

@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 6, 2026
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@Richiealx Richiealx changed the title Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Structuring and Testing Data-Implement_and_Rewrite Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement_and_Rewrite Mar 7, 2026
@github-actions

This comment has been minimized.

@Richiealx Richiealx changed the title Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement_and_Rewrite Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite Mar 7, 2026
@github-actions

This comment has been minimized.

@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 8, 2026
@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 9, 2026
@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 2026
Comment on lines +41 to +45
test(`should return "Invalid angle" for angles outside valid range`, () => {
expect(getAngleType(0)).toEqual("Invalid angle");
expect(getAngleType(360)).toEqual("Invalid angle");
expect(getAngleType(-10)).toEqual("Invalid angle");
}); No newline at end of file
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 make this description more informative by indicating what this "valid range" is.

Copy link
Author

Choose a reason for hiding this comment

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

I removed the unsupported definition wording in implement/2-is-proper-fraction.js and kept the comments focused on the behavior implemented in the function.

I also updated the Jest description in rewrite-tests-with-jest/1-get-angle-type.test.js so that the invalid range is now stated explicitly.

I pushed the changes to the same branch.

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

This comment has been minimized.

@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 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 12, 2026
@Richiealx Richiealx changed the title Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | coursework/sprint-3-implement-and-rewrite Mar 12, 2026
@github-actions

This comment has been minimized.

@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 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 12, 2026
@Richiealx Richiealx changed the title Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | coursework/sprint-3-implement-and-rewrite Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite Tests Mar 12, 2026
@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 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 12, 2026
@github-actions

This comment has been minimized.

@Richiealx Richiealx changed the title Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite Tests Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Implement and Rewrite Mar 12, 2026
@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 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 12, 2026
@github-actions

This comment has been minimized.

@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 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 12, 2026
@Richiealx Richiealx added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 12, 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.

Changes look good.

Comment on lines +20 to +23
test("should return true for a proper fraction", () => {
expect(isProperFraction(1, 2)).toEqual(true);
expect(isProperFraction(3, 4)).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.

Would be more informative to indicate the conditions
"numerator >= denominator, both values non-negative"
in the description.

This way, the person implementing the function don't have to lookup the definition of "proper fraction" (which they may find a different definition).

});

// Case 6: Invalid angles
test(`should return "Invalid angle" for angles less than or equal to 0, or greater than or equal to 360`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is ok to use pseudo-code in the description if they can make the description more concise.

For example, ... when angle <= 0 or angle >= 360

@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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 12, 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