Skip to content

London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Implement And Rewrite Tests#1045

Open
XiaoQuark wants to merge 10 commits intoCodeYourFuture:mainfrom
XiaoQuark:coursework/sprint-3
Open

London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Implement And Rewrite Tests#1045
XiaoQuark wants to merge 10 commits intoCodeYourFuture:mainfrom
XiaoQuark:coursework/sprint-3

Conversation

@XiaoQuark
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

1 Implement solutions

  • Implemented required functions for files:
    • 1-get-angle-type.js
    • 2-is-proper-fraction.js
    • 3-get-card-value.js
  • Added tests in the above files to cover all possible cases (including error handling).
  • Verified all tests passed.

2 Rewrite tests with Jest

  • Rewrote equivalent test suites in Jest
  • Verified all tests pass via npm test

@XiaoQuark XiaoQuark added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 24, 2026
@netEmmanuel netEmmanuel added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 5, 2026
// 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`, () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this test was deleted?

@netEmmanuel netEmmanuel added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 5, 2026
@XiaoQuark
Copy link
Author

XiaoQuark commented Mar 5, 2026

image

I'm not sure I understand this github message. Is there something I need to do?

@netEmmanuel
Copy link

netEmmanuel commented Mar 6, 2026

@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

@XiaoQuark
Copy link
Author

XiaoQuark commented Mar 6, 2026

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 should return false when the denominator is equal to zero.

Let me know if you were expecting a different edge case to be tested.

@Grajales-K Grajales-K added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 6, 2026
throw new Error(`Invalid card format: "${card}". Expected a string.`);

let cardSuit = card.slice(-1);
let cardRank = card.slice(0, -1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@favourO favourO added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Mar 12, 2026
@XiaoQuark
Copy link
Author

Hi @favourO , thank you for your feedback. I think I have fixed everything you mentioned.
I decided to create a second array of valid ranks to validate them before entering the switch. Not sure if this was the idea you had in mind.

Copy link

@favourO favourO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement, just a little more effort
I added a comment.

function getCardValue(card) {
// TODO: Implement this function
const validSuits = ["♠", "♥", "♦", "♣"];
const validRanks = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants