Repository navigation
London | 26-ITP-Sept | Mars Adesina | Sprint 2 | Practice TDD - #1731
marscancode wants to merge 20 commits into
Conversation
…and 2, tests now pass
…and 3, tests now pass
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?
| test("should return 0 when character does not occur", () => { | ||
| const str = "aaaabcd"; | ||
| const char = "e"; | ||
| 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.
| test('should append "th" to numbers ending in 11, 12, or 13', () => { | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| }); |
There was a problem hiding this comment.
These are numbers exactly equal to 11/12/13, how about larger numbers ended with 11/12/13 ? Please add those tests 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?
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
I implemented the countChar, repeatStr, and getOrdinalNumber functions using Test Driven Development (TDD). I added tests using Jest to verify the expected behaviour of each function.