-
-
Notifications
You must be signed in to change notification settings - Fork 239
Manchester |25-ITP-Sep|Mahtem T. Mengstu |Sprint 3|coursework/sprint-3-implement-and-rewrite #851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Manchester |25-ITP-Sep|Mahtem T. Mengstu |Sprint 3|coursework/sprint-3-implement-and-rewrite #851
Conversation
…ssary functions added
…ote tests in jest
| if (numerator < denominator) { | ||
| return true; | ||
| } | ||
| else if (numerator > denominator){ | ||
| return false; | ||
| } | ||
| else if (numerator === denominator) { | ||
| return false; | ||
| } | ||
| else if (numerator === 0){ | ||
| return (true); | ||
| } | ||
| else if (denominator === 0){ | ||
| return (false); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
The order in which we specify the if statements matter. For example, when
numeratoris-5anddenominatoris0, the condition on line 11 will evaluate totrueand the function will returntrueimmediately when it executes the statement on line 12. -
According to the definition of proper fraction in mathematics:
isProperFraction(-4, 3)should returnfalseisProperFraction(-2, 5)should returntrueisProperFraction(-1, 1)should returnfalseisProperFraction(-2, -3)should returntrue
Can you look up the definition of proper fraction and update your function so that it returns the expected value?
| else if (!isNaN(rank )) { | ||
| return Number(rank); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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". Do you want to consider these strings as valid ranks?
| test("should identify reflex angle (240)", () => { | ||
| expect(getAngleType(240)).toEqual("Reflex angle"); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure thorough testing, we need broad scenarios that cover all possible cases.
Listing individual values, however, can quickly lead to an unmanageable number of test cases.
Instead of writing tests for individual numbers, consider grouping all possible input values into meaningful categories.
Then, select representative samples from each category to test. This approach improves coverage and makes our tests easier to maintain.
For example,
test("should identify reflex angle (180 < angle < 360)", () => {
expect(getAngleType(300)).toEqual("Reflex angle");
expect(getAngleType(359.999)).toEqual("Reflex angle");
expect(getAngleType(180.001)).toEqual("Reflex angle");
});
| test("should return true for a negative fraction", () => { | ||
| expect(isProperFraction(-2, 3)).toEqual(true); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test description is a bit misleading because not all negative fractions are proper fractions.
For example, -4/3 is an improper fraction.
| test("should number cards for (2-10)", () => { | ||
| const aceofSpades = getCardValue("6♠"); | ||
| expect(aceofSpades).toEqual(6); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
The test description is incomplete.
-
We could test multiple values within a test. The boundary case, 2 and 10, are good candidates to test.
| // test("should return 11 for Ace of Spades", () => { | ||
| // const aceofSpades = getCardValue("A♠"); | ||
| // expect(aceofSpades).toEqual(11); | ||
| // }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
We could remove code that's no longer needed (to keep the code clean).
-
The function is not expected to validate the suit character. On line 5, mentioning the suit character in the test description could mislead the person implementing the function into thinking the function needs also to check the suit character.
Learners, PR Template
Self checklist
Changelist
Jest testing was performed.
Questions
Any question will be asked in Slack.