Sheffield | 26-ITP-Jan | Seti Mussa | Sprint 3 | Coursework pratice tdd#1283
Sheffield | 26-ITP-Jan | Seti Mussa | Sprint 3 | Coursework pratice tdd#1283Seti-Jemal wants to merge 6 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
| // Case 4: Number ending with 4 (but not 14) | ||
| test("should append 'th' for number ending with 4 expcet those ending with 14", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(44)).toEqual("44th"); | ||
| expect(getOrdinalNumber(54)).toEqual("54th"); | ||
| }); | ||
|
|
||
| // Case 5: Number ending with 5 (but not 15) | ||
| test("should append 'th' for number ending with 5 except those ending with 15", () => { | ||
| expect(getOrdinalNumber(5)).toEqual("5th"); | ||
| expect(getOrdinalNumber(55)).toEqual("55th"); | ||
| expect(getOrdinalNumber(65)).toEqual("65th"); | ||
| }); |
There was a problem hiding this comment.
What are so special about 14 and 15?
These two test categories do not yet cover all possible numbers not included in the previous test cases. You can consider just creating one test category for all the numbers that should be appended with "th".
However, you should avoid describing these numbers as "all other numbers" because
when a test fails with such a message, it may be unclear what "other numbers" actually refers to.
There was a problem hiding this comment.
Hi CJ,
Thank you for the feedback. I have updated the test, removed 14 and 15, and added the special case as required.
| function repeatStr(n, str) { | ||
| return str.repeat(n); | ||
| } |
There was a problem hiding this comment.
Can this function pass the tests in repeat-str.test.js?
| }); | ||
|
|
||
| // Case 5: Numbers ending with 0, 4, 5, 6, 7, 8, or 9 (but not those ending with 11, 12, or 13) | ||
| test("should append 'th' for number ending with 0, 4, 5, 6, 7, 8, or 9 ,(but not those ending with 11, 12, or 13)", () => { |
There was a problem hiding this comment.
Part the the condition specified in this description does not carry new information, and therefore can be dropped.
Self checklist
Changelist
Write a function that counts how many times a given character appears in a string, and passes all Jest tests.
Questions
N/A