-
-
Notifications
You must be signed in to change notification settings - Fork 345
London | 26-ITP-May | Zadri Abdule | Sprint 3 | Implement & rewrite tests #1329
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
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,33 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { | |
| }); | ||
|
|
||
| // Case 2: Right angle | ||
| test(`should return "Right angle" when angle === 90`, () => { | ||
| expect(getAngleType(90)).toEqual("Right angle"); | ||
| }); | ||
| // Case 3: Obtuse angles | ||
| test(`should return "Obtuse angle" when (90 < angle < 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" when angle === 180`, () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Reflex angles | ||
| test(`should return "Reflex angle" when (180 < angle < 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" when invalid`, () => { | ||
| expect(getAngleType(-1)).toEqual("Invalid angle"); | ||
| expect(getAngleType(0)).toEqual("Invalid angle"); | ||
| expect(getAngleType("90")).toEqual("Invalid angle"); | ||
| expect(getAngleType(1000)).toEqual("Invalid angle"); | ||
| expect(getAngleType(9999.999)).toEqual("Invalid angle"); | ||
| }); | ||
|
Comment on lines
+40
to
+46
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.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,36 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
| // Special case: numerator is zero | ||
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| expect(isProperFraction(0, 0)).toEqual(false); | ||
| expect(isProperFraction(-1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`should return true when numerator is zero and denominator is non-zero`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| expect(isProperFraction(0, -1)).toEqual(true); | ||
| expect(isProperFraction(0, 100)).toEqual(true); | ||
| expect(isProperFraction(0, -100)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return true when absolute value of numerator is less than absolute value of 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. Note: Using pseudocode and notations like |
||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| expect(isProperFraction(1, -2)).toEqual(true); | ||
| expect(isProperFraction(-1, -2)).toEqual(true); | ||
| }); | ||
|
|
||
| test(`should return false when absolute value of numerator is greater than or equal to absolute value of denominator`, () => { | ||
| expect(isProperFraction(1, 1)).toEqual(false); | ||
| expect(isProperFraction(2, 1)).toEqual(false); | ||
| expect(isProperFraction(-1, 1)).toEqual(false); | ||
| expect(isProperFraction(1, -1)).toEqual(false); | ||
| expect(isProperFraction(-1, -1)).toEqual(false); | ||
| }); | ||
|
|
||
| test(`floating point values should be compared using absolute values`, () => { | ||
| expect(isProperFraction(0.5, 1)).toEqual(true); | ||
| expect(isProperFraction(1, 0.5)).toEqual(false); | ||
| expect(isProperFraction(-0.5, 1)).toEqual(true); | ||
| expect(isProperFraction(0.5, -1)).toEqual(true); | ||
| expect(isProperFraction(-0.5, -1)).toEqual(true); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,10 +11,34 @@ test(`Should return 11 when given an ace card`, () => { | |
|
|
||
| // Suggestion: Group the remaining test data into these categories: | ||
| // Number Cards (2-10) | ||
| test(`Should return the numeric value for number cards`, () => { | ||
|
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 also include a test to show that the function is expected to check the suit character. |
||
| expect(getCardValue("2♠")).toEqual(2); | ||
| expect(getCardValue("3♠")).toEqual(3); | ||
| expect(getCardValue("4♠")).toEqual(4); | ||
| expect(getCardValue("5♠")).toEqual(5); | ||
| expect(getCardValue("6♠")).toEqual(6); | ||
| expect(getCardValue("7♠")).toEqual(7); | ||
| expect(getCardValue("8♠")).toEqual(8); | ||
| expect(getCardValue("9♠")).toEqual(9); | ||
| expect(getCardValue("10♠")).toEqual(10); | ||
| }); | ||
|
|
||
| // Face Cards (J, Q, K) | ||
| test(`Should return 10 for face cards (J, Q, K)`, () => { | ||
| expect(getCardValue("J♠")).toEqual(10); | ||
| expect(getCardValue("Q♠")).toEqual(10); | ||
| expect(getCardValue("K♠")).toEqual(10); | ||
| }); | ||
|
|
||
| // Invalid Cards | ||
| test(`Should throw an error for invalid cards`, () => { | ||
| expect(() => getCardValue("1♠")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("A")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("J")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("♠")).toThrow("Invalid card"); | ||
| expect(() => getCardValue("")).toThrow("Invalid card"); | ||
| }); | ||
|
|
||
| // 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.
In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. For examples, "0x02", "2.000", or "0002".
Does your function return the value you expected from each of the following function calls?