Cape Town | 2026-ITP-Jan | Isaac Abodunrin | Sprint 3 | Implement and Rewrite Tests Coursework#956
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Very thorough tests! Well done!
There was a problem hiding this comment.
Isn't 0/1 a proper fraction?
There was a problem hiding this comment.
Good catch -- you're absolutely right since the definition of a proper fraction is where the magnitude of the denominator is great than that of the numerator. It doesn't say the numerator can't be zero, so I've updated the code to correct this
There was a problem hiding this comment.
With this way of expressing the test, the test description
Should return ${rank} when given a card ${cardFace}
would appear 36 times on the console (with different ranks and suits).
Should you need to reduce the number of messages on the console, you can consider grouping similar test cases under one category as
test(`Should return the numerical value of number cards`, () => {
const cardsNumbers = [2, 3, 4, 5, 6, 7, 8, 9, 10];
for (const rank of cardsNumbers) {
for (const suit of suits) {
const cardFace = `${rank}${suit}`;
expect(getCardValue(cardFace)).toEqual(rank);
}
}
}
There was a problem hiding this comment.
Thanks for the tip. I've refactored it so that similar test cases use one category -- there are a lot fewer printouts in the console now
…console printouts
…console printouts
Self checklist
Changelist
Implemented solutions to the following, using console.assert() for basic testing:
Rewrite tests for the solutions above using Jest