Skip to content

London | 26-ITP-May | Anita Amirhaeri | Sprint 3 | implement-and-rewrite - #1568

Open
anitahy73 wants to merge 6 commits into
CodeYourFuture:mainfrom
anitahy73:coursework/sprint-3-implement-and-rewrite
Open

London | 26-ITP-May | Anita Amirhaeri | Sprint 3 | implement-and-rewrite#1568
anitahy73 wants to merge 6 commits into
CodeYourFuture:mainfrom
anitahy73:coursework/sprint-3-implement-and-rewrite

Conversation

@anitahy73

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

Sprint 3 Implement-and-rewrite

Implemented the getAngleType function to classify angles and added comprehensive test cases for different angle types, including acute, right, obtuse, reflex, zero, and complete angles, as well as invalid angles.
Implemented the isProperFraction function to check if a fraction is proper and added test cases for various scenarios.
Implement getCardValue function to validate and return card values. Add tests for valid and invalid card inputs.
Added Jest tests for card value function covering Aces, face cards, number cards, and invalid cards.
@anitahy73 anitahy73 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 26, 2026
Comment on lines +34 to +39
else if(angle === 0){
return "Zero angle"
}
else if(angle === 360){
return "Complete angle"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where did you find the specification of these two angles?

Comment on lines +45 to +55
let rank = card.slice(0, -1)// This is extracting the bit before the suits alone
let suit = card.slice(-1) // THis is extracting the suit in the string

if(!ranks.includes(rank)){
throw new Error("Invalid card")
}
if (!suits.includes(suit)){
throw new Error("Invalid card")
}
if (rank === "A"){
return 11}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation is off.

Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode,
as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?

Comment on lines +12 to +28
test(`should return true when denominator is higher than numerator`, () => {
expect(isProperFraction(0, 1)).toEqual(true);
expect(isProperFraction(2, 7)).toEqual(true);
expect(isProperFraction(89, 101)).toEqual(true);
});
// Special case: numerator or denominator is negative, we consider the absolute values for fractions so ignore the negative signs
test(`should return true when negative/positive numerator is less than the positive/negative denominator`, () => {
expect(isProperFraction(-20, -30)).toEqual(true);
expect(isProperFraction(-1, 2)).toEqual(true);
expect(isProperFraction(58, -68)).toEqual(true);
});
// Special case: numerator or denominator is negative, we consider the absolute values for fractions so ignore the negative signs
test(`should return false when negative/positive numerator is greater than the positive/negative denominator`, () => {
expect(isProperFraction(-50, 10)).toEqual(false);
expect(isProperFraction(100, 2)).toEqual(false);
expect(isProperFraction(-1, -0)).toEqual(false);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • You could use pseudo-code and notations like abs(...) and | ... | in the descriptions to more
    concisely describe the conditions.

  • What are other boundary cases you could also test?

expect(getCardValue("2♦")).toEqual(2);
});
//Case 4: Invalid cards
test(`Should return the invalid suit, invalid card or invalid card`, () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the function is expected to throw an error, we could indicate so in the test description as:

Should throw an error when ...

@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 Jul 27, 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