London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Implement And Rewrite Tests#1045
London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Implement And Rewrite Tests#1045XiaoQuark wants to merge 10 commits intoCodeYourFuture:mainfrom
Conversation
… about cases with numerator = 0
| // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. | ||
|
|
||
| // Special case: numerator is zero | ||
| test(`should return false when denominator is zero`, () => { |
There was a problem hiding this comment.
Is there a reason why this test was deleted?
|
@XiaoQuark, I left a comment on your PR that needs your attention. here: https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/pull/1045/changes#r2891725763 |
|
Hi @netEmmanuel, I mentioned this in my reply yesterday, but just to clarify: I didn’t remove that case. I just rewrote the test so the wording is consistent with my other tests. The “denominator equals 0” scenario is still covered in the test Let me know if you were expecting a different edge case to be tested. |
| throw new Error(`Invalid card format: "${card}". Expected a string.`); | ||
|
|
||
| let cardSuit = card.slice(-1); | ||
| let cardRank = card.slice(0, -1); |
There was a problem hiding this comment.
This looks much cleaner after removing the logs. One small thing to think about: since cardSuit and cardRank aren't reassigned later in the function, is let the most appropriate declaration here?
|
|
||
| if (validSuits.find((suit) => suit === cardSuit)) { | ||
| console.log(cardSuit); | ||
| if (validSuits.includes(cardSuit)) { |
There was a problem hiding this comment.
The suit validation works well here. I’m wondering though; if the suit was invalid, what would happen to the rest of the function? Is there a way we could structure the check so that invalid cases exit earlier and the main logic stays flatter?
| @@ -53,17 +48,16 @@ function getCardValue(card) { | |||
| case "8": | |||
There was a problem hiding this comment.
The numeric ranks (2–10) all follow the same logic. Do you think we need a separate case for each one, or could they be handled with a single rule?
|
Hi @favourO , thank you for your feedback. I think I have fixed everything you mentioned. |
favourO
left a comment
There was a problem hiding this comment.
Great improvement, just a little more effort
I added a comment.
| function getCardValue(card) { | ||
| // TODO: Implement this function | ||
| const validSuits = ["♠", "♥", "♦", "♣"]; | ||
| const validRanks = [ |
There was a problem hiding this comment.
This is a nice improvement,
For the numeric cards, do you think you could check if the rank is between 1 and 10 instead of listing each value from 1 to 10? For example, by converting cardRank to a number and checking something like >= 1 && <= 10.

Learners, PR Template
Self checklist
Changelist
1 Implement solutions
1-get-angle-type.js2-is-proper-fraction.js3-get-card-value.js2 Rewrite tests with Jest
npm test