London | 26-ITP-May | Mandip Sanger| Sprint 3| Practice Tdd - #1597
London | 26-ITP-May | Mandip Sanger| Sprint 3| Practice Tdd#1597mandipsanger wants to merge 15 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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| test("should return 0 when the character does not occur 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 should be more test cases for multiple occurrences because the example just tested the case of character in the whole string.
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| }); | ||
| test('should append "nd" when the number ends with 2', () => { | ||
| expect(getOrdinalNumber(22)).toEqual("22nd"); |
There was a problem hiding this comment.
By referencing to the given example, please add more unique test cases within this test set.
| expect(getOrdinalNumber(22)).toEqual("22nd"); | ||
| }); | ||
| test('should append "rd" when the number ends with 3', () => { | ||
| expect(getOrdinalNumber(23)).toEqual("23rd"); |
There was a problem hiding this comment.
By referencing to the given example, please add more unique test cases within this test set.
| // Case 2: Numbers ending with 11 | ||
| test('should append "th" when the number ends with 11', () => { | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| }); | ||
| // Then the function should return a string by appending "st" to the number. | ||
| test('should append "th" when the number ends with 12', () => { | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| }); | ||
| test('should append "th" when the number is 13', () => { | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| }); |
There was a problem hiding this comment.
It's good that you tested the special cases of 11, 12, and 13. It would be nice if larger values (like 511th or 413th) are tested as well.
There was a problem hiding this comment.
How about empty string (with the same set of counts 3, 1, 0, -1)?
hackertainment
left a comment
There was a problem hiding this comment.
Generally good and in the right direction. Just the test cases can cover more unique scenarios. Keep it up :-)
Learners, PR Template
Self checklist
Changelist
PR sprint 3 tdd