-
-
Notifications
You must be signed in to change notification settings - Fork 337
London | ITP-JAN-2026 | Said Fayaz Sadat | Sprint 3 | coursework/sprint-3/implement-and-rewrite-tests #1221
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
base: main
Are you sure you want to change the base?
Changes from all commits
62f2bc9
5218dc7
4541230
60dd1f1
d0b2a26
22cbee3
9ab2716
a517fe7
40bd7ce
8c587a2
560d5c6
401d8cb
48cfeba
595de00
e21d0fd
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 |
|---|---|---|
|
|
@@ -6,15 +6,51 @@ const getAngleType = require("../implement/1-get-angle-type"); | |
| // including boundary and invalid cases. | ||
|
|
||
| // Case 1: Acute angles | ||
| test(`should return "Acute angle" when (0 < angle < 90)`, () => { | ||
| test(`should return "Acute angle" for angles greater than 0° and less than 90°`, () => { | ||
| // Test various acute angles, including boundary cases | ||
| expect(getAngleType(1)).toEqual("Acute angle"); | ||
| expect(getAngleType(45)).toEqual("Acute angle"); | ||
| expect(getAngleType(89)).toEqual("Acute angle"); | ||
| }); | ||
|
|
||
| // Case 2: Right angle | ||
| test(`should return "Right angle" for exactly 90°`, () => { | ||
| expect(getAngleType(90)).toEqual("Right angle"); | ||
| }); | ||
|
|
||
| // Case 3: Obtuse angles | ||
| test(`should return "Obtuse angle" for angles greater than 90° and less than 180°`, () => { | ||
| expect(getAngleType(91)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(135)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(179)).toEqual("Obtuse angle"); | ||
| }); | ||
|
|
||
| // Case 4: Straight angle | ||
| test(`should return "Straight angle" for exactly 180°`, () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Reflex angles | ||
| test(`should return "Reflex angle" for angles greater than 180° and less than 360°`, () => { | ||
| expect(getAngleType(181)).toEqual("Reflex angle"); | ||
| expect(getAngleType(270)).toEqual("Reflex angle"); | ||
| expect(getAngleType(359)).toEqual("Reflex angle"); | ||
| }); | ||
|
|
||
| // Case 6: Invalid angles | ||
| test(`should return "Invalid angle" for angles less than 1°`, () => { | ||
| expect(getAngleType(-1)).toEqual("Invalid angle"); | ||
| }); | ||
|
|
||
| test(`should return "Invalid angle" for angles greater than 360°`, () => { | ||
| expect(getAngleType(361)).toEqual("Invalid angle"); | ||
| }); | ||
|
|
||
| // Largest valid angle(boundary case) | ||
| test(`should return "Straight angle" when angle is the maximum valid value (360)`, () => { | ||
| expect(getAngleType(360)).toEqual("Straight angle"); | ||
| }); | ||
|
Comment on lines
+41
to
+52
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. You could consider grouping all invalid cases into a category:
and then test few invalid values, including both boundary cases. Note: We can use symbols and notation if they help make the description more concise. |
||
| // Smallest valid angle(boundary case) | ||
| test(`should return "Acute angle" when angle is the minimum valid value (1)`, () => { | ||
| expect(getAngleType(1)).toEqual("Acute angle"); | ||
| }); | ||
|
Comment on lines
+53
to
+56
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. You already have a test like this on line 11. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,32 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
|
|
||
| // 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`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
|
|
||
| // Category 1: Numerator is zero | ||
| test("should return true when numerator is zero and denominator is positive", () => { | ||
| expect(isProperFraction(0, 1)).toBe(true); | ||
| }); | ||
| test("should return true when numerator is zero and denominator is negative", () => { | ||
| expect(isProperFraction(0, -1)).toBe(true); | ||
| }); | ||
|
|
||
| // Category 2: Proper fractions (numerator < denominator) | ||
| test("should return true when numerator is less than denominator", () => { | ||
| expect(isProperFraction(1, 2)).toBe(true); | ||
| expect(isProperFraction(3, 5)).toBe(true); | ||
| expect(isProperFraction(-1, 2)).toBe(true); | ||
| expect(isProperFraction(1, -2)).toBe(true); | ||
| }); | ||
|
|
||
| // Category 3: Improper fractions (numerator >= denominator) | ||
| test("should return false when numerator is greater than or equal to denominator", () => { | ||
|
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 making the description more precise as:
or
|
||
| expect(isProperFraction(2, 1)).toBe(false); | ||
| expect(isProperFraction(5, 5)).toBe(false); | ||
| expect(isProperFraction(-3, 2)).toBe(false); | ||
| expect(isProperFraction(3, -2)).toBe(false); | ||
| }); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Category 4: Denominator is zero | ||
| test("should return false when denominator is zero", () => { | ||
| expect(isProperFraction(1, 0)).toBe(false); | ||
| }); | ||
|
Comment on lines
+33
to
+35
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. This is a good category. 0/0 could be a good value to test. |
||
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.
Please check carefully the specification on lines 4-9.