Repository navigation
London|26-ITP-Sep|Abdennour Hachemi|Sprint 2 |Practice TDD - #1701
AbdennourHachemi wants to merge 19 commits into
Conversation
|
Thanks for working on this..The core exercise implementations look solid overall, but i can see one blocking issue regarding version control configuration that needs to be addressed before merging.
practice-tdd/get-ordinal-number.js: The regex logic works, but switching to numeric modulo operations (num % 100 and num % 10) would make the branching much clearer and easier to maintain. practice-tdd/get-ordinal-number.test.js: Consider adding test cases for 3-digit teen exceptions (e.g., 111, 112, 113) to ensure the suffix rules scale properly. practice-tdd/count.test.js: Minor nit - @jest/globals imports aren't needed since Jest provides them globally, and there's a small typo in numberOfOcurrence (numberOfOccurrence). Once package.json and package-lock.json are un-ignored and the error-throwing behavior is updated, this should be good to go. |
|
Thanks @valentina , i have fixed my code according to your review . please have a look again and see if anything else needs correction. |
hey-hammad
left a comment
There was a problem hiding this comment.
Great implementation overall, a couple minor issues needs attention. Thanks
| @@ -0,0 +1,2 @@ | |||
| node_modules | |||
There was a problem hiding this comment.
a .gitignore file already exist in the root of the repo which is enough.
| expect(getOrdinalNumber(21)).toEqual("21st"); | ||
| expect(getOrdinalNumber(131)).toEqual("131st"); | ||
| }); | ||
|
|
There was a problem hiding this comment.
a test case handling the special cases like 11,12,13,101 & 103 will make this suit more robust.
cjyuan
left a comment
There was a problem hiding this comment.
Implementation is correct.
Some of the tests could be refined.
There was a problem hiding this comment.
-
Could consider testing multiple samples in each test category - higher chance to detect bugs in code.
-
Empty string is often a good edge case to test.
-
When a specification is ambiguous, programmers may need to make reasonable assumptions based on their understanding of the requirements. In this case, the original specification did not explicitly state whether character matching should be case-sensitive. Although most people would likely assume that it is, adding test cases can help document this assumption and make our interpretation of the specification explicit.
Similarly, we should consider adding tests for any other assumptions made during implementation to clarify the intended behavior and ensure these assumptions are consistently understood and validated.
| // Case 4: Numbers ending with any other number (but not 1,2 or 3) | ||
| // When the number ends with 4,5,6 ,7 ,8 or 9 , | ||
| // Then the function should return a string by appending "th" to the number. | ||
| test("should append 'th' for numbers ending with 4,5,6 ,7 ,8 or 9 ", () => { |
There was a problem hiding this comment.
Are all "other digits" covered in this category?
| // When the number ends with ,(111, 112,113) | ||
| // Then the function should return a string by appending "th" to the number. | ||
| test("should append 'th' for numbers ending with ", () => { |
There was a problem hiding this comment.
-
The test description seems incomplete.
-
When a comment repeats information already conveyed in the test description, consider removing it to avoid redundancy.
| test("should append 'th' for numbers in 100's ending with 11, 12 , 13", () => { | ||
| expect(getOrdinalNumber(111)).toEqual("111th"); | ||
| expect(getOrdinalNumber(112)).toEqual("112th"); | ||
| expect(getOrdinalNumber(113)).toEqual("113th"); | ||
| }); |
There was a problem hiding this comment.
Why limit the cases to numbers in the 100's?
| // Case 6:A test case handling the special cases like 11,12,13,101 & 103 | ||
|
|
||
| test("should append 'th' for numbers for 11,12,13 and 'st' for 101 and 'rd' for 103", () => { | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| expect(getOrdinalNumber(101)).toEqual("101st"); | ||
| expect(getOrdinalNumber(103)).toEqual("103rd"); | ||
| }); |
There was a problem hiding this comment.
Why are these five numbers considered special cases? What do you mean by "special"?
There was a problem hiding this comment.
The tests in this script do not yet covered all valid cases.
| //handle a non number inputs | ||
| if (!num) { | ||
| return ""; | ||
| } |
There was a problem hiding this comment.
What do you mean by a non-number? !num is not a proper way to check if num is a number or not.
Note: You could assume the parameter is always a number in this exercise.
Self checklist
Task code
CYF-1060