Repository navigation
Manchester | 26-ITP-Sept | Rahana Suleiman | Sprint 2 | Practice TDD - #1691
rahanasuleiman8-ship-it wants to merge 10 commits into
Conversation
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.
… and negative values
b39816b to
a1f5c71
Compare
hackertainment
left a comment
There was a problem hiding this comment.
The code generally looks ok to me. Keep it up.
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(5); | ||
| }); |
There was a problem hiding this comment.
This is a special case of str where it is all the char to count. Would it still count correctly if the char just exists in some part of the str?
| test("should return 0 when the character is not found in the string", () => { | ||
| const str = "hello"; | ||
| const char = "z"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
There is a special str that would give 0 anyway. Please add that test case as well. Thank you.
There was a problem hiding this comment.
Your test cases are correct. Just for you to think a little bit more, besides const str = "hello", what special string should also be added to each of the test cases?
|
Good fixes. Actually, for #1691 (comment) , empty string should also be tested with negative number which should throw an error (but some other trainees might return 0). So it may also be worth to include in test cases as well. Since your program is correctly handle the error case, I will let you pass this time and mark this PR as completed. Well done. |
Self checklist
Task code
CYF-1060
Changelist
This PR completes the TDD exercises for countChar, getOrdinalNumber, and a custom repeatStr implementation, fully covered by passing unit test suites verified via npm run test