Repository navigation
London | 26-ITP-Sep | Sakiya Mayow | Sprint 2 | Practice TDD - #1736
zakiaao-tech wants to merge 13 commits into
Conversation
hackertainment
left a comment
There was a problem hiding this comment.
Thank you for your coursework. 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 where the char to count exists in the whole string str. How about other general cases?
There was a problem hiding this comment.
I understand that the test where the character fills the whole string is a special case. For general cases, I would also test when the character appears multiple times, once, or not at all, as well as when the string is empty.This then can help me check that the function works under different conditions.
| test("should return 0 when there are no occurrences of a character", () => { | ||
| const str = "hello"; | ||
| const char = "z"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
This test case is correct. However, there is a special str which would give 0 anyway. Can you think of it? If so, please add it 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?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9e0800a to
ee15295
Compare
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Practiced testing before fixing the function. Red, Greed,Refactor.