Skip to content

Manchester | 26-ITP-JAN | Abdu Mussa | Sprint 3 |1-implement-and-rewriting-tests/#1141

Open
Abduhasen wants to merge 2 commits intoCodeYourFuture:mainfrom
Abduhasen:coursework/sprint-3-implement-and-rewrite
Open

Manchester | 26-ITP-JAN | Abdu Mussa | Sprint 3 |1-implement-and-rewriting-tests/#1141
Abduhasen wants to merge 2 commits intoCodeYourFuture:mainfrom
Abduhasen:coursework/sprint-3-implement-and-rewrite

Conversation

@Abduhasen
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

implement and rewriting of tests

Questions

N/A

@Abduhasen Abduhasen added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Mar 3, 2026
Comment on lines +27 to 38
}
const validSuits = ["♠", "♥", "♦", "♣"];
const suit = card.slice(-1);
const rank = card.slice(0, -1);
if (!validSuits.includes(suit)) {
throw new Error("Invalid card");
} else if (rank === "A") return 11;
else if (["J", "Q", "K"].includes(rank)) return 10;
const number = Number(rank);
if (number >= 2 && number <= 10) return number;
throw new Error("Invalid card");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Does your function return the value you expected from each of the following function calls?
getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("0002♠");
  • The code is quite packed, making it harder to read. Could consider dropping the else because the code inside the if-else block either throw an error or return immediately, and then use some empty line to separate the code into "sections".

Comment on lines +42 to +44
expect(getAngleType(0)).toBe("Invalid angle");
expect(getAngleType(-45)).toBe("Invalid angle");
expect(getAngleType(370)).toBe("Invalid angle");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not test both border cases.

Comment on lines 7 to 20
test(`should return false when denominator is zero`, () => {
expect(isProperFraction(1, 0)).toEqual(false);
expect(isProperFraction(0, 1)).toEqual(true);
expect(isProperFraction(0, -1)).toEqual(true);
expect(isProperFraction(18, 1)).toEqual(false);
expect(isProperFraction(7, 3)).toEqual(false);
expect(isProperFraction(1, -2)).toEqual(true);
expect(isProperFraction(-15, -9)).toEqual(false);
expect(isProperFraction(-2, -6)).toEqual(true);
expect(isProperFraction(-137, -71)).toEqual(false);
expect(isProperFraction(-100, -189)).toEqual(true);
expect(isProperFraction(27, 5)).toEqual(false);
expect(isProperFraction(-29, 17)).toEqual(false);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

The test description does not quite match the tests being carried out.

Can you take this opportunity to practice:

  • Group tests into logical categories and then include a few representative cases within each category.
  • Express each category using the pattern "should ____________ when _________________" so that the expected behavior of the function is clearly described

@cjyuan cjyuan 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 11, 2026
@Abduhasen Abduhasen added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants