Skip to content

Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Implement and rewrite tests#1197

Open
libanj0161 wants to merge 8 commits intoCodeYourFuture:mainfrom
libanj0161:Sprint-3-1-implement-and-rewrite-tests
Open

Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Implement and rewrite tests#1197
libanj0161 wants to merge 8 commits intoCodeYourFuture:mainfrom
libanj0161:Sprint-3-1-implement-and-rewrite-tests

Conversation

@libanj0161
Copy link

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

Completed Implement and rewrite tests.

Questions

N/A.

@libanj0161 libanj0161 added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Mar 6, 2026
@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 13, 2026
@libanj0161 libanj0161 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 16, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 16, 2026 11:06
Comment on lines +28 to +31
test("should return correct result when numerator or denominator is negative", () => {
expect(isProperFraction(-5, 9)).toEqual(true);
expect(isProperFraction(-2, 0)).toEqual(false);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider combine this into case 2. Otherwise the description does not quite describe the tests in this category.

You could also consider use the notations |...| in the descriptions of 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.

Are the changes what you was expecting?

Copy link
Contributor

@cjyuan cjyuan Mar 18, 2026

Choose a reason for hiding this comment

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

"correct result" is a bit vague. Ideally it should indicate what the correct result is.

What I meant in my previous comment was, you could test both positive and negative values in the test described as
should return true when |numerator| < |denominator|

If you prefer to test positive and mixed cases separately, you could consider:
should return true when |numerator| < |denominator| (positive numerator and denominator)
should return true when |numerator| < |denominator| (negative numerator or denominator)

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
@libanj0161 libanj0161 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 18, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 18, 2026 11:16
// Case 7: Invalid angles
test(`should return "Invalid angles" when (angle >360)`, () => {
// Case 6: Invalid angles
test(`should return "Invalid angles" when (angle is =<0 &&>=360)`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

<= would probably look more natural than =< to programmers.

Copy link
Author

Choose a reason for hiding this comment

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

i've made that change, thank you.

Comment on lines +50 to +51
else if (Number(rank) >= 2 && Number(rank) <= 10) {
return Number(rank);
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.

Done, thank you.

Comment on lines +28 to +31
test("should return correct result when numerator or denominator is negative", () => {
expect(isProperFraction(-5, 9)).toEqual(true);
expect(isProperFraction(-2, 0)).toEqual(false);
});
Copy link
Contributor

@cjyuan cjyuan Mar 18, 2026

Choose a reason for hiding this comment

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

"correct result" is a bit vague. Ideally it should indicate what the correct result is.

What I meant in my previous comment was, you could test both positive and negative values in the test described as
should return true when |numerator| < |denominator|

If you prefer to test positive and mixed cases separately, you could consider:
should return true when |numerator| < |denominator| (positive numerator and denominator)
should return true when |numerator| < |denominator| (negative numerator or denominator)

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 18, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 18, 2026 14:47
@libanj0161 libanj0161 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 18, 2026
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tested your implementation with this script?

Copy link
Author

Choose a reason for hiding this comment

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

yes and it passed

Copy link
Contributor

@cjyuan cjyuan Mar 19, 2026

Choose a reason for hiding this comment

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

Unless you have different files on your computer, I don't see how your function can pass this test. Both the function implementation and the tests have bugs.

Copy link
Author

Choose a reason for hiding this comment

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

ok ill fix those bugs, thanks

Copy link
Author

Choose a reason for hiding this comment

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

Altered function to pass failing test.

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

A string without a suit character is to be considered an invalid card. I guess you misunderstood the spec. A fix should be pretty straight forward, so I will mark this as "Complete" first.

Comment on lines +29 to +32
// Case 3: Number Cards (2-10)
test(`Should return numerical value when given an number card`, () => {
expect(getCardValue("5")).toEqual(5);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Supposedly a valid card is a string in this format: "5♠".

"5" (without the suit character), would be considered an invalid card.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, ive changed that.

Copy link
Contributor

@cjyuan cjyuan Mar 19, 2026

Choose a reason for hiding this comment

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

Function implementation is correct.

This test category is supposed for valid number cards.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 19, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 19, 2026 16:25
@libanj0161 libanj0161 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 19, 2026
@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 19, 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. Module-Structuring-And-Testing-Data The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants