Skip to content

Conversation

@zilinskyte
Copy link

@zilinskyte zilinskyte commented Nov 5, 2025

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

Tests implemented and rewritten with Jest.

Questions

The last commit was accidental when trying to fix issue with previous commit which is failing the PR target test. Please advise.

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@zilinskyte zilinskyte changed the title West Midlands | ITP-SEPT-25 | Georgina Rogera | Sprint 3 | Coursework Sprint 3 West Midlands | ITP-SEPT-25 | Georgina Rogeras| Sprint 3 | Coursework Sprint 3 Nov 5, 2025
@zilinskyte zilinskyte changed the title West Midlands | ITP-SEPT-25 | Georgina Rogeras| Sprint 3 | Coursework Sprint 3 West Midlands | ITP-SEPT-25 | Georgina Rogers | Sprint 3 | Coursework Sprint 3 Nov 5, 2025
@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@zilinskyte zilinskyte changed the title West Midlands | ITP-SEPT-25 | Georgina Rogers | Sprint 3 | Coursework Sprint 3 West Midlands | ITP-SEPT-25 | Georgina Rogers | Sprint 3 | 1-implement-and-rewrite-tests Nov 5, 2025
@zilinskyte zilinskyte added 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 Nov 6, 2025
@zilinskyte zilinskyte changed the title West Midlands | ITP-SEPT-25 | Georgina Rogers | Sprint 3 | 1-implement-and-rewrite-tests West Midlands | ITP-SEPT-25 | Georgina Rogers | Sprint 3 | Implement and rewrite tests Nov 6, 2025
Comment on lines 2 to 6
if (numerator < denominator) {
return true;
} else {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this function to work also for negative parameters? For example, make isProperFraction(4, -5) evaluates to true.

Comment on lines +6 to +9
if (!isNaN(rank) && Number(rank) >= 2 && Number(rank) <= 10) {
// checks for number cards 2-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 or parsed into a valid integers.
Do you want to recognize these string values as valid ranks?

To find out what these strings are, you can ask AI

What kinds of string values would make Number(rank) evaluate to 2 in JS?

or

What kind of string values could pass this check !isNaN(rank) && Number(rank) >= 2 && Number(rank) <= 10?

Comment on lines +15 to +17
test("should return false for a negative fraction", () => {
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.

  • Test description is misleading.

Comment on lines +10 to +12
test("should return false for an improper fraction", () => {
expect(isProperFraction(5, 4)).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.

We could test multiple values (including negative numbers) within this test to make the coverage more complete.

Comment on lines +11 to +15
test("should return 7 for 7 of Hearts", () => {
const sevenOfHearts = getCardValue("7♥");
expect(sevenOfHearts).toEqual(7);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual card, we will need about 53 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples.

For example, one possible category for getCardValue() is, "should return the value of number cards (2-10)", and we can prepare the test as

test("should return the value of number cards (2-10)", () => {
    expect(getCardValue("2♣︎")).toEqual(2);
    expect(getCardValue("5♠")).toEqual(5);
    expect(getCardValue("10♥")).toEqual(10);
    // Note: We could also use a loop to check all values from 2 to 10.
});

Comment on lines +17 to +21
test("should return 10 for King of Hearts", () => {
const kingOfHearts = getCardValue("K♥");
expect(kingOfHearts).toEqual(10);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

The function is not expected to test the suit character. Describing the suit character in the test description could mislead the person implementing the function into thinking the function needs also to check the suit character.

@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 Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants