London | ITP-Jan-26 | Alexandru Pocovnicu | Sprint 3 | Practice TDD#987
London | ITP-Jan-26 | Alexandru Pocovnicu | Sprint 3 | Practice TDD#987alexandru-pocovnicu wants to merge 10 commits intoCodeYourFuture:mainfrom
Conversation
…d negative numbers
…, with error handling for negative counts
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
4 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| let numberLastDigit = numberToString[numberToString.length - 1]; | ||
| let numberLast2Digits = numberToString.slice(numberToString.length - 2); |
There was a problem hiding this comment.
.slice(-N) is clear enough to indicate it extract the last N characters from a string, regardless of string length.
| test("should repeat string count times", () => { | ||
| const str = "bye"; | ||
| const count = 1; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("bye"); | ||
| }); | ||
|
|
||
| // Case: Handle count of 0: | ||
| // Given a target string `str` and a `count` equal to 0, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return an empty string. | ||
| test("should repeat string count times", () => { |
There was a problem hiding this comment.
Can you revise these test descriptions to make the failure messages more informative, so it's immediately clear both what caused the test to fail and what the expected outcome was?
| test("should append 'th' for numbers ending with any number including 11,12 or 13, except those ending with 1,2 or 3", () => { | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| expect(getOrdinalNumber(25)).toEqual("25th"); | ||
| expect(getOrdinalNumber(111)).toEqual("111th"); | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| }); |
There was a problem hiding this comment.
Can you add more test cases to this group to make the coverage more comprehensive?
If the number of cases becomes too large, you can consider organizing them into meaningful subcategories.
There was a problem hiding this comment.
done, how do i decide how many are enough?
There was a problem hiding this comment.
It could be subjective sometimes.
I think all suffixes that should be appended with "th" should be be tested.
So numbers that end with 0, 4-9, 11, 12, 13 (especially 11, 12, 13).
|
thank you |
|
Changes look good. |
Learners, PR Template
Self checklist
Changelist
Completed all exercises from practice tdd