London | 26-ITP-May | Anita Amirhaeri | Sprint 3 | implement-and-rewrite - #1568
London | 26-ITP-May | Anita Amirhaeri | Sprint 3 | implement-and-rewrite#1568anitahy73 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.
| else if(angle === 0){ | ||
| return "Zero angle" | ||
| } | ||
| else if(angle === 360){ | ||
| return "Complete angle" | ||
| } |
There was a problem hiding this comment.
Where did you find the specification of these two angles?
| 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} |
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
?
| 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); | ||
| }); |
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`, () => { |
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 ...
Learners, PR Template
Self checklist
Changelist
Sprint 3 Implement-and-rewrite