Skip to content

Commit f0af80d

Browse files
committed
Add comprehensive tests for isProperFraction function covering edge cases and various scenarios
1 parent 6563959 commit f0af80d

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,37 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
// Special case: numerator is zero
12+
test("should return false when denominator is zero", () => {
13+
expect(isProperFraction(1, 0)).toEqual(false);
14+
});
15+
16+
// Positive proper fractions
17+
test("should return true for positive proper fractions", () => {
18+
expect(isProperFraction(1, 2)).toEqual(true);
19+
expect(isProperFraction(3, 4)).toEqual(true);
20+
});
21+
22+
// Positive improper fractions
23+
test("should return false for positive improper fractions", () => {
24+
expect(isProperFraction(5, 2)).toEqual(false);
25+
expect(isProperFraction(4, 4)).toEqual(false); // equal numerator/denominator
26+
});
27+
28+
// Negative numbers
29+
test("should handle negative numerators and denominators", () => {
30+
expect(isProperFraction(-1, 2)).toEqual(true);
31+
expect(isProperFraction(1, -2)).toEqual(true);
32+
expect(isProperFraction(-3, -4)).toEqual(true);
33+
expect(isProperFraction(-5, 2)).toEqual(false);
34+
});
35+
36+
// Numerator is zero
37+
test("should return true when numerator is zero and denominator is non-zero", () => {
38+
expect(isProperFraction(0, 5)).toEqual(true);
39+
});
40+
41+
// Both zero
42+
test("should return false when both numerator and denominator are zero", () => {
43+
expect(isProperFraction(0, 0)).toEqual(false);
44+
});

0 commit comments

Comments
 (0)