Skip to content

Manchester | 26-ITP-May | Szidonia Bodo | Sprint 3 | Implement and review test#1520

Open
bodoszidi wants to merge 6 commits into
CodeYourFuture:mainfrom
bodoszidi:Sprint-3.1
Open

Manchester | 26-ITP-May | Szidonia Bodo | Sprint 3 | Implement and review test#1520
bodoszidi wants to merge 6 commits into
CodeYourFuture:mainfrom
bodoszidi:Sprint-3.1

Conversation

@bodoszidi

@bodoszidi bodoszidi commented Jul 16, 2026

Copy link
Copy Markdown

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

Created a new pull request only for implementation and review test

@github-actions

This comment has been minimized.

@bodoszidi bodoszidi 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 Jul 16, 2026
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 16, 2026
@github-actions

This comment has been minimized.

@bodoszidi bodoszidi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 16, 2026
@Liam310 Liam310 added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 21, 2026
return true;
} else {
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you ever find yourself with a solution that looks like

if (condition) {
  return true;
} else {
  return false;
}

And the condition itself is a boolean value (i.e. it evaluates to true or false), there's a more succinct way we can write the code. Can you think what it might be?

assertEquals(isProperFraction(-8, 2), false);
assertEquals(isProperFraction(4, 0), false);
assertEquals(isProperFraction(0, 0), false);
assertEquals(isProperFraction(-2, -2), false)

@Liam310 Liam310 Jul 22, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you were to check the case of isProperFraction(-1, 2), what do we want to see as the answer? And would that test pass?

(Things get a little awkwardly mathsy with negative fractions, I recognise)

return Number(removeSuit);
} else {
throw new Error("Error")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A great solution, very readable 👌

Just one point, you've declared let removeSuit - should this be a let or a const? In either case, why?

assertEquals(getCardValue("J♦"), 10);
assertEquals(getCardValue("7♥"), 7);
assertEquals(getCardValue("A♥"), 11);
assertEquals(getCardValue("8♥"), 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.

When writing a test suite, we want to try and cover all possible "behaviours" of our function. Here I can see you've covered:

  • Hearts
  • Spades
  • Diamonds
  • Numbered cards
  • Jacks
  • Aces

Looking at that list, what have you not covered?

Comment on lines +17 to +46
test(`should return "Right angle" when (angle = 90)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(90)).toEqual("Right angle");
});
// Case 3: Obtuse angles
test(`should return "Obtuse angle" when (angle < 180, angle > 90)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(91)).toEqual("Obtuse angle");
expect(getAngleType(179)).toEqual("Obtuse angle");
expect(getAngleType(99)).toEqual("Obtuse angle");
});
// Case 4: Straight angle
test(`should return "Straight angle" when (angle = 180)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(180)).toEqual("Straight angle");
});
// Case 5: Reflex angles
test(`should return "Reflex angle" when (angle < 360, angle > 180)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(189)).toEqual("Reflex angle");
expect(getAngleType(359)).toEqual("Reflex angle");
expect(getAngleType(199)).toEqual("Reflex angle");
});
// Case 6: Invalid angles
test(`should return "Invalid angle" when (angle > 361, angle < 0)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(505)).toEqual("Invalid angle");
expect(getAngleType(0)).toEqual("Invalid angle");
expect(getAngleType(699)).toEqual("Invalid angle");
}); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You've left a comment in all these tests which doesn't seem relevant to them - get rid!


test(`should return false when denominator is bigger than the numerator`, () => {
expect(isProperFraction(5, -2)).toEqual(false);
expect(isProperFraction(-1, 0)).toEqual(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expect(isProperFraction(-1, 0)).toEqual(false);

This test case, which test does it belong in? What grouping of behaviours does it fall into?


test(`Should return 10 when given the Queen card`, () => {
expect(getCardValue("Q♠")).toEqual(10);
});

@Liam310 Liam310 Jul 22, 2026

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 tests are pretty decent (maybe worth considering my above comment for whether there's a couple more you could add), but I want to talk about the test descriptions at the moment.

Generally speaking, we don't always want to be so specific as to describe exactly what's happening in the assertion. Think about the previous function, your test descriptions were great! You separated it into

  • When the numerator is bigger than the denominator
  • When the numerator is smaller than the denominator

Rather than saying "returns true when numerator is 4 and denominator is 6", which would be too specific.

Some of these tests are understandably individualised, such as testing for "Q♠" - there's a very specific input that will only produce one output. But on the contrary, your tests on lines 16, 24, and 28 are all really testing the same behaviour, so probably ought to be one test. My question for you is: what would be a good test description for that test?

@Liam310

Liam310 commented Jul 22, 2026

Copy link
Copy Markdown

Hey @bodoszidi! 👋

Good work on your first journey into using tests. Writing tests from scratch is not easy, it's a skill that takes a while to develop but there's a lot of good stuff in here.

My comments are mostly about focussing on how to organise our test cases. The main things we want to be doing are:

  • Trying to achieve good test coverage, which means "have we considered all possible scenarios here?"
  • Defining tests according to "behaviours" of the function, which means thinking about "how does the function behave with a certain type of input?" and figuring out how to group those inputs when relevant. A good rule of thumb is: if they're all handled by the same bit of logic in the function, they should probably be grouped as part of the same behaviour.

Please do respond to any comments with answers or further questions if you aren't sure what I'm talking about! 😄

@Liam310 Liam310 added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 22, 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. 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