-
-
Notifications
You must be signed in to change notification settings - Fork 386
Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Implement and rewrite test #1130
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 8 commits
6f5bc6a
0de9751
b4dc07e
9b97ed0
7a64436
221bb71
f99a296
a1aff3b
f10a8d4
98734bf
71445dc
362f624
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,7 +4,31 @@ 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 | ||
| // Special case: denominator is zero | ||
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| // Case: numerator is zero | ||
| test(`should return true when numerator is zero and denominator is positive`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| }); | ||
| test("should return true when numerator is smaller than denominator and both are positive", () => { | ||
| 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); | ||
| }); | ||
|
|
||
| test("should return false when numerator is negative", () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| test("should return true when both numerator and denominator are negative and numerator is smaller than denominator", () => { | ||
| expect(isProperFraction(-1, -2)).toEqual(true); | ||
| }); | ||
|
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. The test description on line 28 is not quite accurate. For proper fractions, the condition is, "the absolute value of denominator is larger than the absolute value of the numerator". So we can create a category for proper fractions and describe it as: and then test all combinations of positive/negative numerator and denominator (for proper fraction) in this category.
Author
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. Thank you for the feedback. I’ve updated the tests to follow the rule that a proper fraction is when |
||
Uh oh!
There was an error while loading. Please reload this page.