generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 241
Manchester| 25-ITP-September | Fithi Teklom| Sprint 3 | 2-practice-tdd #863
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
Open
Fithi-Teklom
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
Fithi-Teklom:2-practice-tdd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+118
−33
Open
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
31f50ad
count.js updated
Fithi-Teklom a61f9b1
updated pr template
Fithi-Teklom 2a422f5
updated PR template
Fithi-Teklom 04f5a7f
get ordinal numbers updated template
Fithi-Teklom 7e9160d
ordinal numbers updated PR template
Fithi-Teklom 6c17f89
repeat.js updated template
Fithi-Teklom 94de70c
repeat.test.js updated template
Fithi-Teklom 44ce568
adjusted Pr template
Fithi-Teklom 8eaf08c
Added comment
Fithi-Teklom e145d3c
Resolved merge conflict: kept repeat.js
Fithi-Teklom e7cad87
count.test.js passed all the tests
Fithi-Teklom 17a2043
deleted repeat.js and adjusted repeat.str.test.js
Fithi-Teklom 4f483dd
modified PR
Fithi-Teklom 9e31389
nothing changed
Fithi-Teklom f409459
restored 3-stretch from origin/main
Fithi-Teklom 78dd2fd
restored Sprint2 5-stretch-extend
Fithi-Teklom 84090e8
moved the test to the test.js file
Fithi-Teklom e0d530d
made sure the tests all passed.
Fithi-Teklom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,61 @@ | ||
|
|
||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| const remainder10 = num % 10; | ||
| const remainder100 = num % 100; | ||
|
|
||
| if (remainder100 >= 11 && remainder100 <= 13) { | ||
| return `${num}th`; | ||
| } | ||
|
|
||
| switch (remainder10) { | ||
| case 1: | ||
| return `${num}st`; | ||
| case 2: | ||
| return `${num}nd`; | ||
| case 3: | ||
| return `${num}rd`; | ||
| default: | ||
| return `${num}th`; | ||
| } | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; | ||
|
|
||
|
|
||
| const getOrdinalNumber = require("./getOrdinalNumber"); | ||
|
|
||
| describe("getOrdinalNumber()", () => { | ||
| test("should return '1st' for 1", () => { | ||
| expect(getOrdinalNumber(1)).toBe("1st"); | ||
| }); | ||
|
|
||
| test("should return '2nd' for 2", () => { | ||
| expect(getOrdinalNumber(2)).toBe("2nd"); | ||
| }); | ||
|
|
||
| test("should return '3rd' for 3", () => { | ||
| expect(getOrdinalNumber(3)).toBe("3rd"); | ||
| }); | ||
|
|
||
| test("should return '4th' for 4", () => { | ||
| expect(getOrdinalNumber(4)).toBe("4th"); | ||
| }); | ||
|
|
||
| test("should return '11th', '12th', '13th' for special cases", () => { | ||
| expect(getOrdinalNumber(11)).toBe("11th"); | ||
| expect(getOrdinalNumber(12)).toBe("12th"); | ||
| expect(getOrdinalNumber(13)).toBe("13th"); | ||
| }); | ||
|
|
||
| test("should return correct suffixes for 21, 22, 23", () => { | ||
| expect(getOrdinalNumber(21)).toBe("21st"); | ||
| expect(getOrdinalNumber(22)).toBe("22nd"); | ||
| expect(getOrdinalNumber(23)).toBe("23rd"); | ||
| }); | ||
cjyuan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| test("should return '111th' for numbers ending with 11, 12, 13 even if larger", () => { | ||
| expect(getOrdinalNumber(111)).toBe("111th"); | ||
| expect(getOrdinalNumber(112)).toBe("112th"); | ||
| expect(getOrdinalNumber(113)).toBe("113th"); | ||
| }); | ||
| }); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
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. Have you tried running this test script to make sure it can run properly?
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. Now I have made sure that the tests have all passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const repeat = require("./repeat"); | ||
|
|
||
| function repeat() { | ||
| return "hellohellohello"; | ||
| } | ||
|
|
||
| module.exports = repeat; | ||
|
|
||
| test("should repeat the given word three times", () => { | ||
| expect(repeat("hi", 3)).toBe("hihihi"); | ||
| }); | ||
cjyuan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.