-
-
Notifications
You must be signed in to change notification settings - Fork 398
London | 26-ITP-May | Jorvan White | Sprint 3 | Implement and Rewrite Tests #1601
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
4c62400
376a6b0
2323e10
87fbee5
57e3a65
bf5c332
4ca3f91
185c7e7
195189a
3f957a1
b48031e
216221a
d10fc3c
60638b4
2ac2702
f8cf7cf
f3f69db
f6f3d1d
0bdef75
630c502
55740a4
6994606
e54bbd5
9aaaa7e
7cacfb4
a6131ab
a85a823
cc958de
919dba4
6e8feda
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 |
|---|---|---|
|
|
@@ -14,7 +14,36 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { | |
| }); | ||
|
|
||
| // Case 2: Right angle | ||
| 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 | ||
| // Case 4: Straight angle | ||
| test(`should return "Obtuse angle" when (90 < angle < 180)`, () => { | ||
| // Test various obtuse angles, including boundary cases | ||
| 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" 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 (180 < angle < 360)`, () => { | ||
| // Test various reflex angles, including boundary cases | ||
| 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" when (angle < 0 || angle > 360)`, () => { | ||
|
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. Besides |
||
| // Test various invalid angles | ||
| expect(getAngleType(-1)).toEqual("Invalid angle"); | ||
| expect(getAngleType(361)).toEqual("Invalid angle"); | ||
| }); | ||
|
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. there should be more negative number test cases. Can you think of them? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,31 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when numerator is zero`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when numerator is negative`, () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when denominator is negative`, () => { | ||
| expect(isProperFraction(1, -2)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when both numerator and denominator are negative`, () => { | ||
| expect(isProperFraction(-1, -2)).toEqual(false); | ||
|
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 one should expect true |
||
| }); | ||
|
|
||
| test(`should return true when numerator is less than denominator`, () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return false when numerator is equal to denominator`, () => { | ||
| expect(isProperFraction(2, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return false when numerator is greater than denominator`, () => { | ||
| expect(isProperFraction(3, 2)).toEqual(false); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,28 @@ test(`Should return 11 when given an ace card`, () => { | |
| }); | ||
|
|
||
| // Suggestion: Group the remaining test data into these categories: | ||
| // Number Cards (2-10) | ||
| // Face Cards (J, Q, K) | ||
| // Invalid Cards | ||
| // Case 2 Number Cards (2-10) | ||
| test(`Should return the same number when given a number card of any suit`, () => { | ||
| expect(getCardValue("3♠")).toEqual(3); | ||
| }); | ||
|
|
||
| // Case 3 Face Cards (J, Q, K) | ||
| test(`Should return 10 when given an any face card`, () => { | ||
| expect(getCardValue("J♠")).toEqual(10); | ||
| expect(getCardValue("Q♥")).toEqual(10) | ||
| expect(getCardValue("K♦")).toEqual(10) | ||
| }); | ||
|
|
||
|
|
||
| // Invalid Cards | ||
| // test(`Cards without suits return as Invalid card`, () => { | ||
| // expect(getCardValue("10")).toEqual(new Error); | ||
| // }); | ||
| test('Cards without suits return as Invalid card', () => { | ||
| expect(() => { | ||
| getCardValue("10"); | ||
| }).toThrow("Invalid card"); | ||
| }); | ||
|
Comment on lines
+26
to
+34
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. there should be more invalid cases, Can you think of them? |
||
| // To learn how to test whether a function throws an error as expected in Jest, | ||
| // please refer to the Jest documentation: | ||
| // https://jestjs.io/docs/expect#tothrowerror | ||
|
|
||
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.
This
ifcondition seems not quite right. Why (-2)/(-3) would return false?