London | 26-ITP-May | Liridona Shehu | Sprint 3 | Implement and rewrite#1474
London | 26-ITP-May | Liridona Shehu | Sprint 3 | Implement and rewrite#1474shehu-dona wants to merge 32 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
| else if( angle > 180 && angle < 360){ | ||
| return "Reflex angle"; | ||
| } | ||
| else return "Invalid angle"; |
There was a problem hiding this comment.
FYI: You don't need the else here as the code will only run if no other condition was true
| if( angle > 0 && angle < 90){ | ||
| return "Acute angle"; | ||
| } | ||
| else if (angle === 90){ | ||
| return "Right angle"; | ||
| } | ||
| else if ( angle > 90 && angle < 180){ | ||
| return "Obtuse angle"; | ||
| } | ||
| else if(angle === 180){ | ||
| return "Straight angle"; | ||
| } | ||
| else if( angle > 180 && angle < 360){ |
There was a problem hiding this comment.
I see some white spaces in the conditions that are not needed. How can you ensure consistent formatting in your code?
There was a problem hiding this comment.
I updated json file and added "editor.defaultFormatter": "esbenp.prettier-vscode"
| test(`should return "Invalid angle" when (180 < angle < 360)`, () => { | ||
| // Test various invalid angles, including boundary cases | ||
| expect(getAngleType(0)).toEqual("Invalid angle"); | ||
| expect(getAngleType(360)).toEqual("Invalid angle"); |
There was a problem hiding this comment.
You could add 2 test cases that are not boundary cases
There was a problem hiding this comment.
Added more test cases that are not boundary cases.
There was a problem hiding this comment.
Which test cases did you add? I do not see any new ones.
| // Special case: numerator is negative is a proper fraction | ||
| test(`should return false when numerator is negative value`, () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(false); | ||
| }); | ||
|
|
||
|
|
||
| // Special case: denominator is negative is a proper fraction |
There was a problem hiding this comment.
The comments say is a prober fracteion but the function should return false. This is confusing
| }); | ||
|
|
||
|
|
||
| // Special case: negative numerator with smaller value then negative dominator is a proper fraction |
There was a problem hiding this comment.
The comments say is a prober fracteion but the function should return false. This is confusing
| const validRanks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; | ||
| const validSuits = ["♠", "♥", "♦", "♣"]; | ||
|
|
||
| let isValidRank = validRanks.includes(rank); | ||
| let isValidSuit = validSuits.includes(suit); | ||
|
|
||
|
|
||
|
|
||
| // Invalid Card | ||
| if( !isValidRank || !isValidSuit ){ | ||
| throw new Error("Invalid Card") |
There was a problem hiding this comment.
Thats a nice way of checking if the input is valid. By expliciting stating all allowed values that code is easy to understand
| // test(`Should throw an error when given an invalid card`, () => { | ||
| // expect(() => getCardValue("1♠")).toThrow(); | ||
| // expect(() => getCardValue("Z♦")).toThrow(); | ||
| // expect(() => getCardValue("11♥")).toThrow(); | ||
| // expect(() => getCardValue("")).toThrow(); | ||
| // }); | ||
|
|
There was a problem hiding this comment.
Never used toThrow() function before so I used the example as a reference why I was typing but forgot to remove it at the end.I removed unnecessary comments.
|
Hello @Luro91, I read your comments and and updated the work. |
I don't see some of the changes you mentioned. Maybe they were not pushed? |
|
Hello @Luro91, |
Luro91
left a comment
There was a problem hiding this comment.
Negative fractions still need correct handling.
My tip for verifying that your submission is pushed: Always check the files changes page of the PR and see if the changes and the commits show up in Github: https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/pull/1474/changes
|
Hello @Luro91 |
Luro91
left a comment
There was a problem hiding this comment.
Well done. The code is working correctly now .
|
Thank you for reviewing my PR |
Learners, PR Template
Self checklist
Changelist
A PR with exercises using Jest