Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3 | coursework/sprint-3-practice-tdd#1249
Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3 | coursework/sprint-3-practice-tdd#1249marthak1 wants to merge 10 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
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 append 'th' for numbers ending with 4", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(20)).toEqual("20th"); | ||
| expect(getOrdinalNumber(100)).toEqual("100th"); | ||
| }); |
There was a problem hiding this comment.
Does this category only cover numbers ending with 4?
There was a problem hiding this comment.
Thanks for the feedback. The category covers 4,5,6,7,8,9 and 0. But only these test cases will be covered. Amended the test decription to reflect this
| test("should repeat the string count times", () => { | ||
| const str = "hello"; | ||
| const count = 1; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hello"); | ||
| }); | ||
| // Case: Handle count of 0: | ||
| // Given a target string `str` and a `count` equal to 0, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return an empty string. | ||
|
|
||
| test("should repeat the string count times", () => { | ||
| const str = "hello"; | ||
| const count = 0; |
There was a problem hiding this comment.
Three of the tests in this file have the same description. When a test fails, it will take longer time to find out which of them fails.
Can you make these descriptions distinct and more informative?
| // Given a target string `str` and a negative integer `count`, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should throw an error, as negative counts are not valid. | ||
| test(`Should throw an error`, () => { |
There was a problem hiding this comment.
Can you also describe the condition of which the function is expected to throw an error?
For example, in the form Should throw an error when ...
Removed console.log statement from character counting loop.
| }); | ||
|
|
||
| // Case 2: Numbers ending in 2 → add nd → (2nd, 22nd, 42nd) | ||
| test("should append 'nd' for numbers ending with 2", () => { |
There was a problem hiding this comment.
It is probably better to clarify this category does not include numbers ending with 12.
| expect(getOrdinalNumber(142)).toEqual("142nd"); | ||
| }); | ||
| // Case 3: Numbers ending in 3 → add rd → (3rd, 23rd, 53rd) | ||
| test("should append '3rd' for numbers ending with 3", () => { |
There was a problem hiding this comment.
Could also update this description to exclude numbers like 13, 113.
Learners, PR Template
Self checklist
Changelist
Implement practice TDD exercises