Repository navigation
London | 26-ITP-Sept | Mars Adesina | Sprint 2 | Practice TDD - #1731
marscancode wants to merge 24 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.
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.
thankyou! i've added another test.
| 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.
There was a problem hiding this comment.
thankyou! i've added it now.
| 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.
This a good point. I've now added these tests. Thankyou!
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?
There was a problem hiding this comment.
This was helpful to think about. I've added the tests now. thankyou!
|
Congratulation, you have completed this PR successfully. If you would like to learn more about test cases design process (i.e. using minimum number of tests to provide maximum coverage of cases), please feel free to book a mentored coding session with a volunteer. :-) |
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.