Manchester | 26-ITP-JAN | Abdu Mussa | Sprint 3 |1-implement-and-rewriting-tests/#1141
Open
Abduhasen wants to merge 2 commits intoCodeYourFuture:mainfrom
Open
Manchester | 26-ITP-JAN | Abdu Mussa | Sprint 3 |1-implement-and-rewriting-tests/#1141Abduhasen wants to merge 2 commits intoCodeYourFuture:mainfrom
Abduhasen wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Mar 11, 2026
Comment on lines
+27
to
38
| } | ||
| const validSuits = ["♠", "♥", "♦", "♣"]; | ||
| const suit = card.slice(-1); | ||
| const rank = card.slice(0, -1); | ||
| if (!validSuits.includes(suit)) { | ||
| throw new Error("Invalid card"); | ||
| } else if (rank === "A") return 11; | ||
| else if (["J", "Q", "K"].includes(rank)) return 10; | ||
| const number = Number(rank); | ||
| if (number >= 2 && number <= 10) return number; | ||
| throw new Error("Invalid card"); | ||
| } |
Contributor
There was a problem hiding this comment.
- Does your function return the value you expected from each of the following function calls?
getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("0002♠");
- The code is quite packed, making it harder to read. Could consider dropping the
elsebecause the code inside the if-else block either throw an error or return immediately, and then use some empty line to separate the code into "sections".
Comment on lines
+42
to
+44
| expect(getAngleType(0)).toBe("Invalid angle"); | ||
| expect(getAngleType(-45)).toBe("Invalid angle"); | ||
| expect(getAngleType(370)).toBe("Invalid angle"); |
Contributor
There was a problem hiding this comment.
Why not test both border cases.
Comment on lines
7
to
20
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| expect(isProperFraction(0, -1)).toEqual(true); | ||
| expect(isProperFraction(18, 1)).toEqual(false); | ||
| expect(isProperFraction(7, 3)).toEqual(false); | ||
| expect(isProperFraction(1, -2)).toEqual(true); | ||
| expect(isProperFraction(-15, -9)).toEqual(false); | ||
| expect(isProperFraction(-2, -6)).toEqual(true); | ||
| expect(isProperFraction(-137, -71)).toEqual(false); | ||
| expect(isProperFraction(-100, -189)).toEqual(true); | ||
| expect(isProperFraction(27, 5)).toEqual(false); | ||
| expect(isProperFraction(-29, 17)).toEqual(false); | ||
| }); |
Contributor
There was a problem hiding this comment.
The test description does not quite match the tests being carried out.
Can you take this opportunity to practice:
- Group tests into logical categories and then include a few representative cases within each category.
- Express each category using the pattern "should ____________ when _________________" so that the expected behavior of the function is clearly described
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Learners, PR Template
Self checklist
Changelist
implement and rewriting of tests
Questions
N/A