Repository navigation
London|26-ITP-Sep|Abdennour Hachemi|Sprint 2 |Practice TDD - #1701
AbdennourHachemi wants to merge 12 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.
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return the original `str` without repetition. | ||
|
|
||
| test("should return the original `str` without repetition", () => { |
There was a problem hiding this comment.
In TDD, the test description (or test name) should clearly explain what behavior the function should exhibit.
The goal is that someone reading the test can understand the requirement without reading another spec.
A common format is: should <expected_behavior> when <condition>.
Could you also include the "condition" part into the description?
Self checklist
Task code
CYF-1060