-
-
Notifications
You must be signed in to change notification settings - Fork 387
Glasgow | 25-ITP-Sep | Hanna Mykytiuk | Sprint 3 | practice-tdd #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,3 +34,8 @@ test("should return '12th' for 12", () => { | |
| test("should return '13th' for 13", () => { | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| }); | ||
|
Comment on lines
+16
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure thorough testing, we need broad scenarios that cover all possible cases. For example, we can prepare a test for numbers 2, 22, 132, etc. as Can you make the tests in this script more comprehensive?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I have add it. |
||
| test("append 'nd' to numbers ending in 2, except those ending in 12", () => { | ||
| expect( getOrdinalNumber(2) ).toEqual("2nd"); | ||
| expect( getOrdinalNumber(22) ).toEqual("22nd"); | ||
| expect( getOrdinalNumber(132) ).toEqual("132nd"); | ||
| }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just an example. Why not update the whole test script accordingly to make the test more comprehensive?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I have added other tests. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| function repeat(str, count) { | ||
|
|
||
| if (count < 0){ | ||
| return null | ||
| throw new Error("Count must be positive number!"); | ||
| } | ||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works. An alternative is to throw an exception.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for advice, I have changed it. |
||
| else if (count == 0){ | ||
| return "" | ||
| return ""; | ||
| } | ||
| let result = ""; | ||
| for ( let i=0; i<count; i++){ | ||
| result +=str | ||
| result +=str; | ||
| } | ||
| return result | ||
| return result; | ||
| } | ||
|
|
||
| module.exports = repeat; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could consider naming them
lastDigitandlastTwoDigits(more human readable).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I have changed it.