Skip to content

London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 3 | Implement and rewrite tests.#1171

Open
khaliun-dev wants to merge 9 commits intoCodeYourFuture:mainfrom
khaliun-dev:coursework/sprint-3-implement-and-rewrite-tests
Open

London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 3 | Implement and rewrite tests.#1171
khaliun-dev wants to merge 9 commits intoCodeYourFuture:mainfrom
khaliun-dev:coursework/sprint-3-implement-and-rewrite-tests

Conversation

@khaliun-dev
Copy link

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

Completed all the exercises in implement and rewrite, and performed the necessary tests.

Questions

None so far.

Implemented the getAngleType function to determine angle types and added tests for various cases.
Implement getCardValue function to determine card value based on rank and suit, including error handling for invalid cards.
Added checks for zero denominator and updated test cases for proper fractions.
@khaliun-dev khaliun-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 4, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

  • Functions are correctly implemented

  • Tests are comprehensive

  • Some test descriptions could be made clearer

Comment on lines +13 to +39
test(`should return true when numerator is smaller than denominator`, () => {
expect(isProperFraction(1, 2)).toEqual(true);
expect(isProperFraction(3, 4)).toEqual(true);
});

// Equal numbers → not proper
test(`should return false when numerator equals denominator`, () => {
expect(isProperFraction(2, 2)).toEqual(false);
});

// Improper fractions
test(`should return false when numerator is greater than denominator`, () => {
expect(isProperFraction(5, 4)).toEqual(false);
expect(isProperFraction(10, 3)).toEqual(false);
});

// Zero numerator
test(`should return true when numerator is zero and denominator is non-zero`, () => {
expect(isProperFraction(0, 5)).toEqual(true);
});

// Negative numbers
test(`should handle negative numbers correctly`, () => {
expect(isProperFraction(-1, 2)).toEqual(true);
expect(isProperFraction(1, -2)).toEqual(true);
expect(isProperFraction(-3, -2)).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.

We can use pseudo-code and notations like abs(...) or | ... | in the descriptions to more concisely describe the conditions (the "when" part).

Copy link
Author

Choose a reason for hiding this comment

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

test("|n| < |d| with negative signs → true, |n| > |d| → false", () => {
expect(isProperFraction(-1, 2)).toBe(true);
expect(isProperFraction(1, -2)).toBe(true);
expect(isProperFraction(-3, -2)).toBe(false);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

With this category, when one of the tests fail, it may not be easy to find out whether the function fails to identify proper fraction or improper fraction.

Copy link
Author

Choose a reason for hiding this comment

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

test("|n| < |d| with mixed negative signs → true", () => {
expect(isProperFraction(-1, 2)).toBe(true);
expect(isProperFraction(1, -2)).toBe(true);
});

test("|n| > |d| with both negative → false", () => {
expect(isProperFraction(-3, -2)).toBe(false);
});

A strategy of separating tests by logic as much as possible helps pinpoint the test failure point better?

Copy link
Contributor

Choose a reason for hiding this comment

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

  • Strategy is sound.

  • The format of the test description is quite uncommon. Normal practice is to describe them in the form:
    should <expected_behavior> when <condition>.
    For example, "should return true when |numerator| < |denominator|" (more natural to English-speaking people)

@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 14, 2026
@khaliun-dev khaliun-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Mar 15, 2026

The proposed changes look good. Did you update your code according? I don't see any new commits on this PR branch.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@khaliun-dev
Copy link
Author

Good evening @cjyuan

I have updated my code with the approved changes.

Thanks.

@khaliun-dev khaliun-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Mar 15, 2026

Did you run npm test to ensure your changes did not introduce new bugs? It is a common practice to run tests before code is submitted to a PR.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
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.

2 participants