Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Implement and rewrite tests#1197
Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Implement and rewrite tests#1197libanj0161 wants to merge 8 commits intoCodeYourFuture:mainfrom
Conversation
Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
Outdated
Show resolved
Hide resolved
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
Outdated
Show resolved
Hide resolved
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js
Outdated
Show resolved
Hide resolved
Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
Outdated
Show resolved
Hide resolved
Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js
Outdated
Show resolved
Hide resolved
Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
Show resolved
Hide resolved
| test("should return correct result when numerator or denominator is negative", () => { | ||
| expect(isProperFraction(-5, 9)).toEqual(true); | ||
| expect(isProperFraction(-2, 0)).toEqual(false); | ||
| }); |
There was a problem hiding this comment.
Could consider combine this into case 2. Otherwise the description does not quite describe the tests in this category.
You could also consider use the notations |...| in the descriptions of improper fractions.
There was a problem hiding this comment.
Are the changes what you was expecting?
There was a problem hiding this comment.
"correct result" is a bit vague. Ideally it should indicate what the correct result is.
What I meant in my previous comment was, you could test both positive and negative values in the test described as
should return true when |numerator| < |denominator|
If you prefer to test positive and mixed cases separately, you could consider:
should return true when |numerator| < |denominator| (positive numerator and denominator)
should return true when |numerator| < |denominator| (negative numerator or denominator)
| // Case 7: Invalid angles | ||
| test(`should return "Invalid angles" when (angle >360)`, () => { | ||
| // Case 6: Invalid angles | ||
| test(`should return "Invalid angles" when (angle is =<0 &&>=360)`, () => { |
There was a problem hiding this comment.
<= would probably look more natural than =< to programmers.
There was a problem hiding this comment.
i've made that change, thank you.
| else if (Number(rank) >= 2 && Number(rank) <= 10) { | ||
| return Number(rank); |
There was a problem hiding this comment.
In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. For examples, "0x02", "2.1", or "0002".
Does your function return the value you expected from each of the following function calls?
getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("0002♠");
| test("should return correct result when numerator or denominator is negative", () => { | ||
| expect(isProperFraction(-5, 9)).toEqual(true); | ||
| expect(isProperFraction(-2, 0)).toEqual(false); | ||
| }); |
There was a problem hiding this comment.
"correct result" is a bit vague. Ideally it should indicate what the correct result is.
What I meant in my previous comment was, you could test both positive and negative values in the test described as
should return true when |numerator| < |denominator|
If you prefer to test positive and mixed cases separately, you could consider:
should return true when |numerator| < |denominator| (positive numerator and denominator)
should return true when |numerator| < |denominator| (negative numerator or denominator)
There was a problem hiding this comment.
Have you tested your implementation with this script?
There was a problem hiding this comment.
Unless you have different files on your computer, I don't see how your function can pass this test. Both the function implementation and the tests have bugs.
There was a problem hiding this comment.
ok ill fix those bugs, thanks
There was a problem hiding this comment.
Altered function to pass failing test.
cjyuan
left a comment
There was a problem hiding this comment.
A string without a suit character is to be considered an invalid card. I guess you misunderstood the spec. A fix should be pretty straight forward, so I will mark this as "Complete" first.
| // Case 3: Number Cards (2-10) | ||
| test(`Should return numerical value when given an number card`, () => { | ||
| expect(getCardValue("5")).toEqual(5); | ||
| }); |
There was a problem hiding this comment.
Supposedly a valid card is a string in this format: "5♠".
"5" (without the suit character), would be considered an invalid card.
There was a problem hiding this comment.
Function implementation is correct.
This test category is supposed for valid number cards.
Learners, PR Template
Self checklist
Changelist
Completed Implement and rewrite tests.
Questions
N/A.