Skip to content

London | 26-ITP-Sep | Abakar Souleyman | Sprint 3 | Practice tdd - #1661

Open
abmhts wants to merge 6 commits into
CodeYourFuture:mainfrom
abmhts:coursework/sprint-3-practice-tdd
Open

abmhts wants to merge 6 commits into
CodeYourFuture:mainfrom
abmhts:coursework/sprint-3-practice-tdd

Conversation

@abmhts

@abmhts abmhts commented Oct 8, 2026

Copy link
Copy Markdown

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

Task code

CYF-1060

Changelist

Practice TDD

@abmhts abmhts added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 8, 2026
@hackertainment hackertainment added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 9, 2026

@hackertainment hackertainment left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The code looks good and you are almost there. Please keep it up :-)

Comment on lines +25 to +31
test("should return 0 when character doesn't occur", () => {
const str = "salam";
const char = "b";

const count = countChar(str, char);
expect(count).toEqual(0);
}); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There should be another valid boundary case that returns 0. Can you think of it? Please add it back. Thank you.

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.

Added another boundary case when the string is empty.
Thank you.

Comment on lines +33 to +42
// Case 4: Numbers ending with "th" including the special case (11,12,13)
test(`Numbers ending with "th" including the special case (11,12,13)`, () => {
expect(getOrdinalNumber(10)).toEqual("10th");
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
expect(getOrdinalNumber(14)).toEqual("14th");
expect(getOrdinalNumber(5)).toEqual("5th");
expect(getOrdinalNumber(4)).toEqual("4th");
}); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test suite should include more test cases that is greater than 100 and still ended in th. Please add them back. Thank you.

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.

Included numbers greater than 100 ending with "th" & with the special case (111, 112, 113).
Thank you.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your answers are correct. Just to give you a bit more thinking, besides const str = "hello"; , what special string should also be tested in each of the test suites?

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.

Added an empty string tests for repeatStr.
Thank you.

@hackertainment hackertainment added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 9, 2026
@abmhts abmhts added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 11, 2026
Comment on lines 56 to +65
// Case: Handle negative count:
// Given a target string `str` and a negative integer `count`,
// When the repeatStr function is called with these inputs,
// Then it should throw an error, as negative counts are not valid.
test("should return an error, as negative counts are not valid", () => {
const str = "hello";
const count = -1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("negative counts are not valid");
});

@hackertainment hackertainment Oct 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just not sure whether you have learnt this topic already or it will be covered in the later modules... When the question mentioned that "it should throw an error", it does not mean return an error but using throw new Error() in line 5 of your practice-tdd/repeat-str.js and using the Jest function .toThrow() (but not .toEqual()) for this particular test case. Since this programming concept may be quite new to you, if you need help on understanding what I commented here, please feel free to ask a volunteer in Saturday workshop or book a mentored coding session with a volunteer, and try to fix this last issue (which I have missed in the first review) in both practice-tdd/repeat-str.js and practice-tdd/repeat-str.test.js when count is a negative number. Thank you for your effort and you have done a very good job.

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

Labels

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