London | 26-ITP-May | Anita Amirhaeri | Sprint 3 | implement-and-rewrite - #1568
Open
anitahy73 wants to merge 6 commits into
Open
London | 26-ITP-May | Anita Amirhaeri | Sprint 3 | implement-and-rewrite#1568anitahy73 wants to merge 6 commits into
anitahy73 wants to merge 6 commits into
Conversation
Implemented the getAngleType function to classify angles and added comprehensive test cases for different angle types, including acute, right, obtuse, reflex, zero, and complete angles, as well as invalid angles.
Implemented the isProperFraction function to check if a fraction is proper and added test cases for various scenarios.
Implement getCardValue function to validate and return card values. Add tests for valid and invalid card inputs.
Added Jest tests for card value function covering Aces, face cards, number cards, and invalid cards.
cjyuan
reviewed
Jul 27, 2026
Comment on lines
+34
to
+39
| else if(angle === 0){ | ||
| return "Zero angle" | ||
| } | ||
| else if(angle === 360){ | ||
| return "Complete angle" | ||
| } |
Contributor
There was a problem hiding this comment.
Where did you find the specification of these two angles?
Comment on lines
+45
to
+55
| let rank = card.slice(0, -1)// This is extracting the bit before the suits alone | ||
| let suit = card.slice(-1) // THis is extracting the suit in the string | ||
|
|
||
| if(!ranks.includes(rank)){ | ||
| throw new Error("Invalid card") | ||
| } | ||
| if (!suits.includes(suit)){ | ||
| throw new Error("Invalid card") | ||
| } | ||
| if (rank === "A"){ | ||
| return 11} |
Contributor
There was a problem hiding this comment.
Indentation is off.
Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode,
as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?
Comment on lines
+12
to
+28
| test(`should return true when denominator is higher than numerator`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| expect(isProperFraction(2, 7)).toEqual(true); | ||
| expect(isProperFraction(89, 101)).toEqual(true); | ||
| }); | ||
| // Special case: numerator or denominator is negative, we consider the absolute values for fractions so ignore the negative signs | ||
| test(`should return true when negative/positive numerator is less than the positive/negative denominator`, () => { | ||
| expect(isProperFraction(-20, -30)).toEqual(true); | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| expect(isProperFraction(58, -68)).toEqual(true); | ||
| }); | ||
| // Special case: numerator or denominator is negative, we consider the absolute values for fractions so ignore the negative signs | ||
| test(`should return false when negative/positive numerator is greater than the positive/negative denominator`, () => { | ||
| expect(isProperFraction(-50, 10)).toEqual(false); | ||
| expect(isProperFraction(100, 2)).toEqual(false); | ||
| expect(isProperFraction(-1, -0)).toEqual(false); | ||
| }); |
Contributor
There was a problem hiding this comment.
-
You could use pseudo-code and notations like
abs(...)and| ... |in the descriptions to more
concisely describe the conditions. -
What are other boundary cases you could also test?
| expect(getCardValue("2♦")).toEqual(2); | ||
| }); | ||
| //Case 4: Invalid cards | ||
| test(`Should return the invalid suit, invalid card or invalid card`, () => { |
Contributor
There was a problem hiding this comment.
If the function is expected to throw an error, we could indicate so in the test description as:
Should throw an error when ...
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
Sprint 3 Implement-and-rewrite