Skip to content

Scotland | ITP JAN-2026 | Tuan Nguyen | Sprint 3 | 2- Practice-tdd#1258

Open
Jacknguyen4438 wants to merge 6 commits intoCodeYourFuture:mainfrom
Jacknguyen4438:Jest-test-case-sprint-3B
Open

Scotland | ITP JAN-2026 | Tuan Nguyen | Sprint 3 | 2- Practice-tdd#1258
Jacknguyen4438 wants to merge 6 commits intoCodeYourFuture:mainfrom
Jacknguyen4438:Jest-test-case-sprint-3B

Conversation

@Jacknguyen4438
Copy link
Copy Markdown

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

I have done practice and fully understand how to write a test for both normal JS and Jest test.

Questions

No Question.

@Jacknguyen4438 Jacknguyen4438 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 13, 2026
// Case 5: All other numbers
// When the number does not end with 1, 2, or 3,
// Then the function should append "th".
test("should append 'th' for all other numbers", () => {
Copy link
Copy Markdown
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.
Can you revise the test description to make it more informative?

Copy link
Copy Markdown
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 feed back I will fix it right away

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test description still reads: "should append 'th' for all other numbers"

@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 14, 2026
@Jacknguyen4438
Copy link
Copy Markdown
Author

@cjyuan Hello thank you for the review, I see there are many part that need to be fix and improve. I will check all 5 part that you would like me to explain and fix each of them. When I finish I will mention you again to ask for a review.

@Jacknguyen4438
Copy link
Copy Markdown
Author

@cjyuan Hello, thank you for spending your time your time to do my PR, I am very grateful for you help. I have make change base on you suggestion and ready to be review

@Jacknguyen4438 Jacknguyen4438 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
// Case 5: All other numbers
// When the number does not end with 1, 2, or 3,
// Then the function should append "th".
test("should append 'th' for all other numbers", () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test description still reads: "should append 'th' for all other numbers"

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@Jacknguyen4438
Copy link
Copy Markdown
Author

@cjyuan Hello I have make change needed for review again. If I have make another error I need to be done please let me know.

@Jacknguyen4438 Jacknguyen4438 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
Copy link
Copy Markdown
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 -64 to -65
test("should return error for invalid input", () => {
expect(() =>getOrdinalNumber(1.2)).toThrow("Invalid input");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: "Return an error" is not the same as "throw an error".

Comment on lines +65 to +70
expect(() => getOrdinalNumber(1.2)).toThrow("Invalid input");
expect(() => getOrdinalNumber(1.8)).toThrow("Invalid input");
expect(() => getOrdinalNumber(2.5)).toThrow("Invalid input");
expect(() => getOrdinalNumber(10.51)).toThrow("Invalid input");
expect(() => getOrdinalNumber(12.49)).toThrow("Invalid input");
expect(() => getOrdinalNumber(12.5)).toThrow("Invalid input");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why test so many decimal numbers with decimal point? If the objective is to show the function should treat any number with decimal points as invalid input, one or two samples should be enough.

Under the "invalid input" category, it would probably be more useful to show what other kinds of input are considered invalid. For examples,

  • "300" -- a string that resembles an integer
  • Infinity
  • NaN

@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 27, 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