-
-
Notifications
You must be signed in to change notification settings - Fork 339
West Midlands | 25 Sep ITP | Iswat Bello | Sprint 3 | Implement and rewrite tests #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 27 commits
f17635b
3766d27
f9eea26
cfda58c
b7a2183
f028f06
fec9455
0032765
69ddec4
8c717df
028ec7d
6bcf17a
00515f5
31446ec
121ebe4
b46a6d3
273a36a
48f2143
9705d12
5c5e00b
a66ab62
3b9f415
5e0b672
8daafbd
050e86a
df7ccfb
46aee35
47809af
cfecb6c
9a88261
7a4e526
5411c34
3b5e67d
bbde7ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,23 +4,70 @@ const getAngleType = require("../implement/1-get-angle-type"); | |
|
|
||
| test("should identify right angle (90°)", () => { | ||
| expect(getAngleType(90)).toEqual("Right angle"); | ||
| expect(getAngleType(90.0)).toEqual("Right angle"); | ||
| }); | ||
|
|
||
| // REPLACE the comments with the tests | ||
| // make your test descriptions as clear and readable as possible | ||
|
|
||
| // Case 2: Identify Acute Angles: | ||
| // When the angle is less than 90 degrees, | ||
| // When the angle is greater than 0 degrees and less than 90 degrees, | ||
| // Then the function should return "Acute angle" | ||
| test("should identify acute angle (<90°)", () => { | ||
| expect(getAngleType(50)).toEqual("Acute angle"); | ||
| expect(getAngleType(45)).toEqual("Acute angle"); | ||
| expect(getAngleType(89.999)).toEqual("Acute angle"); | ||
| }); | ||
|
|
||
| // Case 3: Identify Obtuse Angles: | ||
| // When the angle is greater than 90 degrees and less than 180 degrees, | ||
| // Then the function should return "Obtuse angle" | ||
| test("should identiify obtuse angle (>90° and <180°)", () => { | ||
| expect(getAngleType(91)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(120)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(179.999)).toEqual("Obtuse angle"); | ||
| }); | ||
|
|
||
| // Case 4: Identify Straight Angles: | ||
| // When the angle is exactly 180 degrees, | ||
| // Then the function should return "Straight angle" | ||
| test("should identify straight angle (180°)", () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| expect(getAngleType(180.0)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Identify Reflex Angles: | ||
| // When the angle is greater than 180 degrees and less than 360 degrees, | ||
| // Then the function should return "Reflex angle" | ||
| test("should identify reflex angle (>180° and <360°)", () => { | ||
| expect(getAngleType(250)).toEqual("Reflex angle"); | ||
| expect(getAngleType(181)).toEqual("Reflex angle"); | ||
| expect(getAngleType(270)).toEqual("Reflex angle"); | ||
| expect(getAngleType(359.999)).toEqual("Reflex angle"); | ||
| }); | ||
|
|
||
| // Case 6: Identify Full Rotation: | ||
| // When the angle is exactly 360 degrees, | ||
| // Then the function should return "Full rotation" | ||
| test("should identify full roatation angle 360°", () => { | ||
| expect(getAngleType(360)).toEqual("Full rotation"); | ||
| }); | ||
|
Comment on lines
+42
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make a test more robust, we could specify multiple |
||
|
|
||
| // Case 7: Handle Invalid Angles: | ||
| // When the angle is negative or greater than 360 or any other data type | ||
| // Then the function should return "Invalid angle" | ||
| test("should return 'Invalid angle' for negative, >360, or non-numeric values", () => { | ||
| expect(getAngleType(-10)).toEqual("Invalid angle"); | ||
| expect(getAngleType(400)).toEqual("Invalid angle"); | ||
| expect(getAngleType("abc")).toEqual("Invalid angle"); | ||
| expect(getAngleType(true)).toEqual("Invalid angle"); | ||
| expect(getAngleType(null)).toEqual("Invalid angle"); | ||
| expect(getAngleType(undefined)).toEqual("Invalid angle"); | ||
| }); | ||
|
|
||
| // Case 8: Identify Zero Angle: | ||
| // When the angle is exactly 0 degrees, | ||
| // Then the function should return "Zero angle" | ||
| test("should return 'Zero angle' when the input is 0", () => { | ||
| expect(getAngleType(0)).toEqual("Zero angle"); | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,27 @@ test("should return 11 for Ace of Spades", () => { | |
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return the numeric value for number cards from 2 to 10", () => { | ||
| expect(getCardValue("7♥")).toEqual(7); | ||
| expect(getCardValue("2♥")).toEqual(2); | ||
| expect(getCardValue("10♥")).toEqual(10); | ||
| }) | ||
|
Comment on lines
+11
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could consider testing multiple values, especially the boundary cases "2♥" and "10♥". |
||
|
|
||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("should return 10 for face cards", () => { | ||
| const faceCard = getCardValue("J♥"); | ||
| expect(faceCard).toEqual(10); | ||
| }) | ||
|
|
||
| // Case 4: Handle Ace (A): | ||
| test("should return 11 for ace card", () => { | ||
| const aceCard = getCardValue("A♥"); | ||
| expect (aceCard).toEqual(11); | ||
| }) | ||
|
|
||
| // Case 5: Handle Invalid Cards: | ||
| test("should return invalid card rank for random numbers", () => { | ||
| expect(getCardValue("85♠")).toEqual("Invalid card rank."); | ||
| expect(getCardValue("1♠")).toEqual("Invalid card rank."); | ||
| expect(getCardValue("")).toEqual("Invalid card rank."); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In math, 2/-3 equals to -2/3, and -2/-3 is equal to 2/3. So a fraction could still be considered as a proper fraction even if its denominator is negative.
-2/3 is a proper fraction.
Suggestion: Lookup the definition of proper fraction. You may also need to update the tests accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjyuan.
Thank you for the clarification! You’re absolutely right. The sign of the denominator doesn’t affect whether a fraction is proper, and I should be comparing the absolute values instead.
I’ll update the function to handle negative denominators and negative numerators correctly and update the tests accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjyuan.
I have updated the function and tests to correctly handle proper fractions with negative numerators or denominators. I also added additional test cases to ensure the function produces the expected output.
Thank you.