-
-
Notifications
You must be signed in to change notification settings - Fork 259
Glasgow | 25-ITP-Sep | Fares Bakhet | Sprint 3 | coursework/sprint-3-practice-tdd #757
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 3 commits
6ab27fc
9c2b470
48dba8f
76de1ca
7323aba
80cde9a
bea3492
44f3ca1
c2a674b
7d3028f
1590eec
2478386
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
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 scenario coverage. Listing individual values, however, can quickly lead to an unmanageable number of test cases. For example, we can prepare a test for numbers 2, 22, 132, etc. as
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. @cjyuan, Done 🫡 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,90 +4,27 @@ const getOrdinalNumber = require("./get-ordinal-number"); | |
| // continue testing and implementing getOrdinalNumber for additional cases | ||
| // Write your tests using Jest - remember to run your tests often for continual feedback | ||
|
|
||
| // Case 1: Identify the ordinal number for 1 | ||
| // When the number is 1, | ||
| // Then the function should return "1st" | ||
|
|
||
| test("should return '1st' for 1", () => { | ||
| test("append 'st' to numbers ending in 1,except those ending in 11", () => { | ||
| expect(getOrdinalNumber(1)).toEqual("1st"); | ||
| }); | ||
|
|
||
| // Case 2: Identify the ordinal number for 2 | ||
| // When the number is 2, | ||
| // Then the function should return "2nd" | ||
|
|
||
| test("should return '2nd' for 2", () => { | ||
| expect(getOrdinalNumber(2)).toEqual("2nd"); | ||
| }); | ||
|
|
||
| // Case 3: Identify the ordinal number for 3 | ||
| // When the number is 3, | ||
| // Then the function should return "3rd" | ||
|
|
||
| test("should return '3rd' for 3", () => { | ||
| expect(getOrdinalNumber(3)).toEqual("3rd"); | ||
| }); | ||
|
|
||
| // Case 4: Identify the ordinal number for 4 | ||
| // When the number is 4, | ||
| // Then the function should return "4th" | ||
|
|
||
| test("should return '4th' for 4", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| }); | ||
|
|
||
| // Case 5: Identify the ordinal number for 11 | ||
| // When the number is 11, | ||
| // Then the function should return "11th" | ||
|
|
||
| test("should return '11th' for 11", () => { | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| }); | ||
|
|
||
| // Case 6: Identify the ordinal number for 12 | ||
| // When the number is 12, | ||
| // Then the function should return "12th" | ||
|
|
||
| test("should return '12th' for 12", () => { | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| }); | ||
|
|
||
| // Case 7: Identify the ordinal number for 13 | ||
| // When the number is 13, | ||
| // Then the function should return "13th" | ||
|
|
||
| test("should return '13th' for 13", () => { | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| }); | ||
|
|
||
| // Case 8: Identify the ordinal number for 21 | ||
| // When the number is 21, | ||
| // Then the function should return "21st" | ||
|
|
||
| test("should return '21st' for 21", () => { | ||
| expect(getOrdinalNumber(21)).toEqual("21st"); | ||
| expect(getOrdinalNumber(101)).toEqual("101st"); | ||
| }); | ||
|
|
||
| // Case 9: Identify the ordinal number for 22 | ||
| // When the number is 22, | ||
| // Then the function should return "22nd" | ||
|
|
||
| test("should return '22nd' for 22", () => { | ||
| 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"); | ||
| }); | ||
|
|
||
| // Case 10: Identify the ordinal number for 23 | ||
| // When the number is 23, | ||
| // Then the function should return "23rd" | ||
|
|
||
| test("should return '23rd' for 23", () => { | ||
| test("append 'rd' to numbers ending in 3, except those ending in 13", () => { | ||
| expect(getOrdinalNumber(3)).toEqual("3rd"); | ||
| expect(getOrdinalNumber(23)).toEqual("23rd"); | ||
| expect(getOrdinalNumber(133)).toEqual("133rd"); | ||
| }); | ||
|
|
||
| // Case 11: Identify the ordinal number for 101 | ||
| // When the number is 101, | ||
| // Then the function should return "101st" | ||
|
|
||
| test("should return '101st' for 101", () => { | ||
| expect(getOrdinalNumber(101)).toEqual("101st"); | ||
| test("should return 'th' for the rest numbers", () => { | ||
|
||
| expect(getOrdinalNumber(10)).toEqual("10th"); | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| expect(getOrdinalNumber(34)).toEqual("34th"); | ||
| expect(getOrdinalNumber(134)).toEqual("134th"); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| function repeat() { | ||
| const str = arguments[0]; | ||
| const count = arguments[1]; | ||
| function repeat(str, count) { | ||
| //const str = arguments[0]; | ||
| //const count = arguments[1]; | ||
|
||
| if (count < 0) { | ||
| throw new Error("Count must be a non-negative integer"); | ||
| } | ||
|
|
||
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.
Since you have decided to remove the optional
else, why only remove the last else?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.
@cjyuan, Okay