Skip to content

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

Closed
XiaoQuark wants to merge 11 commits into
CodeYourFuture:mainfrom
XiaoQuark:coursework/sprint-3
Closed

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

Conversation

@XiaoQuark

Copy link
Copy Markdown

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`, () => {

Copy link
Copy Markdown

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

XiaoQuark commented Mar 5, 2026

Copy link
Copy Markdown
Author
image

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

@netEmmanuel

netEmmanuel commented Mar 6, 2026

Copy link
Copy Markdown

@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

XiaoQuark commented Mar 6, 2026

Copy link
Copy Markdown
Author

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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.

@favourO favourO left a comment

Copy link
Copy Markdown

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
Copy Markdown

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.

@XiaoQuark XiaoQuark added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 16, 2026
@XiaoQuark

Copy link
Copy Markdown
Author

@favourO
Sorry for the late reply. I refactored the code as requested.

@XiaoQuark XiaoQuark removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Mar 17, 2026

@favourO favourO left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All done now.

const numericRank = Number(cardRank);

const validNumericRank =
Number.isInteger(numericRank) && numericRank >= 2 && numericRank <= 10;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job, exactly what I was looking for

@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. labels Mar 22, 2026
@XiaoQuark

Copy link
Copy Markdown
Author

Thank you @favourO ,

Do you think the PR could be marked as completed then?

@favourO favourO added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 27, 2026
@illicitonion

Copy link
Copy Markdown
Member

Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it.

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

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants