-
-
Notifications
You must be signed in to change notification settings - Fork 241
London | 25-ITP-Sep | Adnaan Abo | Sprint 3 | coursework/sprint-3-practice-tdd #718
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
889f34e
c40ecef
f097ae0
09a628b
a87356b
8b8e22f
b31f116
daf6efa
c7bc598
4183f3b
c3eae64
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 |
|---|---|---|
|
|
@@ -8,70 +8,59 @@ const getOrdinalNumber = require("./get-ordinal-number"); | |
| // When the number is 1, | ||
| // Then the function should return "1st" | ||
|
|
||
| test("should return '1st' for 1", () => { | ||
| // category 1: ends with 1 (but not 11) -> "st" | ||
| test("append 'st' to numbers ending in 1, except those ending in 11", () => { | ||
| expect(getOrdinalNumber(1)).toEqual("1st"); | ||
| expect(getOrdinalNumber(21)).toEqual("21st"); | ||
| expect(getOrdinalNumber(101)).toEqual("101st"); | ||
| }); | ||
|
|
||
| // 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", () => { | ||
| // category 2: ends with 2 (but not 12) -> "nd" | ||
| 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(102)).toEqual("102nd"); | ||
| }); | ||
|
|
||
| // 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", () => { | ||
| // category 3: ends with 3 (but not 13) -> "rd" | ||
| 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(103)).toEqual("103rd"); | ||
| }); | ||
|
|
||
| // 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", () => { | ||
| // category 4: all other numbers -> "th" | ||
| test("append 'th' to all other numbers", () => { | ||
| 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"); | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| expect(getOrdinalNumber(14)).toEqual("14th"); | ||
| expect(getOrdinalNumber(111)).toEqual("111th"); | ||
| expect(getOrdinalNumber(112)).toEqual("112th"); | ||
| expect(getOrdinalNumber(113)).toEqual("113th"); | ||
|
Comment on lines
+49
to
+54
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. Why test the same numbers again in a separate test?
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. You are right all the test under category 5: special case for 11, 12, 13 -> "th" can be removed since they are tested in category 4: all other numbers -> "th" |
||
| expect(getOrdinalNumber(114)).toEqual("114th"); | ||
| }); | ||
|
|
||
| // Case 6: 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"); | ||
| }); | ||
|
|
||
| // Case 7: Identify the ordinal number for 102 | ||
| // When the number is 102, | ||
| // Then the function should return "102nd" | ||
|
|
||
| test("should return '102nd' for 102", () => { | ||
| expect(getOrdinalNumber(102)).toEqual("102nd"); | ||
| }); | ||
|
|
||
| // Case 8: Identify the ordinal number for 111 | ||
| // When the number is 111, | ||
| // Then the function should return "111th" | ||
|
|
||
| test("should return '111th' for 111", () => { | ||
| // category 5: special case for 11, 12, 13 -> "th" | ||
| test("append 'th' to numbers ending in 11, 12, or 13", () => { | ||
| expect(getOrdinalNumber(11)).toEqual("11th"); | ||
| expect(getOrdinalNumber(12)).toEqual("12th"); | ||
| expect(getOrdinalNumber(13)).toEqual("13th"); | ||
| expect(getOrdinalNumber(111)).toEqual("111th"); | ||
| expect(getOrdinalNumber(112)).toEqual("112th"); | ||
| expect(getOrdinalNumber(113)).toEqual("113th"); | ||
| }); | ||
|
|
||
| // case 9: identify the ordinal number for 211 | ||
| // when the number is 211 | ||
| // then the function should return "211th" | ||
|
|
||
| test("should return '33rd' for 33", () => { | ||
| expect(getOrdinalNumber(33)).toEqual("33rd"); | ||
| }); | ||
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.
When this test fails, the description "all other numbers" is not quite informative; one would need to read the other tests to figure out what numbers are considered as "other numbers".
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.
fixed to more detailed description, "append 'th' to numbers ending in 0, 4–9, or 11–13"