Skip to content

London | 25-ITP-May | Hendrine Zeraua | Sprint 3 | Structuring and Testing Data #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

rarityXtreme
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

1- key-implement
2- mandatory-rewrite
3- mandatory-practice
4- stretch-investigate

Questions

No questions at the moment.

@rarityXtreme rarityXtreme added the Needs Review Participant to add when requesting review label Jul 16, 2025
@cjyuan cjyuan added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jul 17, 2025
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.

Code is very solid. Good job.

I think some of the tests can be made more comprehensive.

Comment on lines 15 to 17
test("should return '2nd' for 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

To ensure thorough testing, we need broad scenario coverage. Listing individual values, however, can quickly lead to an unmanageable number of test cases.
Instead of writing tests for individual numbers, consider grouping all possible input values into meaningful categories. Then, select representative samples from each category to test. This approach improves coverage and makes our tests easier to maintain.

For example, we can prepare a test for numbers 2, 22, 132, etc. as

test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
    expect( getOrdinalNumber(2) ).toEqual("2nd");
    expect( getOrdinalNumber(22) ).toEqual("22nd");
    expect( getOrdinalNumber(132) ).toEqual("132nd");
});

Can you update the tests so that they can cover all valid integers?

Copy link
Author

Choose a reason for hiding this comment

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

I grouped the ordinal number tests by suffix categories to cover all valid integers with fewer, clearer cases. The function stays the same since it already works correctly.

Comment on lines 3 to 9
test("validates a correct card number: 9999777788880000", () => {
expect(validateCreditCard("9999777788880000")).toBe(true);
});

test("validates a correct card number: 6666666666661666", () => {
expect(validateCreditCard("6666666666661666")).toBe(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

These two tests can be combined and placed under the category "should return true for valid card number".

We don't usually describe the specific value we are testing unless such value is a unique value.

Copy link
Author

Choose a reason for hiding this comment

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

HI CJ,
Thanks for the suggestion! I've grouped the valid card tests under one case for clarity and maintainability. All tests now focus on meaningful categories instead of specific values.

Thanks again for reviewing my work.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and review comments have been addressed Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Complete Volunteer to add when work is complete and review comments have been addressed labels Jul 17, 2025
@rarityXtreme rarityXtreme added the Needs Review Participant to add when requesting review label Jul 18, 2025
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. Well done.

Comment on lines 38 to 43
test("appends 'th' to all other numbers", () => {
expect(getOrdinalNumber(4)).toBe("4th");
expect(getOrdinalNumber(9)).toBe("9th");
expect(getOrdinalNumber(100)).toBe("100th");
expect(getOrdinalNumber(111)).toBe("111th");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

When a test fails with the message "... all other numbers", it may be unclear what "other numbers" actually refers to. A more specific and informative message, such as "... numbers ending in 0 or 4–9", would make the output easier to understand and act on.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the final test description to be more specific ("numbers ending in 0 or 4–9") as suggested. No changes to test logic.

Thank you very much.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and review comments have been addressed and removed Needs Review Participant to add when requesting review Reviewed Volunteer to add when completing a review labels Jul 18, 2025
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 review comments have been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants