-
-
Notifications
You must be signed in to change notification settings - Fork 336
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 15 commits
62f2bc9
5218dc7
4541230
60dd1f1
d0b2a26
22cbee3
9ab2716
a517fe7
40bd7ce
8c587a2
560d5c6
401d8cb
48cfeba
595de00
e21d0fd
921a30a
8a9fab6
89c02e7
b3bbf8a
0f7221f
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,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", () => { | ||
|
||
| 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); | ||
| }); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.