Skip to content

Commit f08aec2

Browse files
committed
Rewrite isProperFraction tests using Jest
1 parent 94950b8 commit f08aec2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,36 @@ 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+
// Proper fractions (positive numbers
12+
test(`should return true when numerator is smaller than denominator`, () => {
13+
expect(isProperFraction(1, 2)).toEqual(true);
14+
expect(isProperFraction(3, 4)).toEqual(true);
15+
});
16+
17+
// Equal numbers → not proper
18+
test(`should return false when numerator equals denominator`, () => {
19+
expect(isProperFraction(2, 2)).toEqual(false);
20+
});
21+
22+
// Improper fractions
23+
test(`should return false when numerator is greater than denominator`, () => {
24+
expect(isProperFraction(5, 4)).toEqual(false);
25+
expect(isProperFraction(10, 3)).toEqual(false);
26+
});
27+
28+
// Zero numerator
29+
test(`should return true when numerator is zero and denominator is non-zero`, () => {
30+
expect(isProperFraction(0, 5)).toEqual(true);
31+
});
32+
33+
// Negative numbers
34+
test(`should handle negative numbers correctly`, () => {
35+
expect(isProperFraction(-1, 2)).toEqual(true);
36+
expect(isProperFraction(1, -2)).toEqual(true);
37+
expect(isProperFraction(-3, -2)).toEqual(false);
38+
});
39+
40+
// Both zero
41+
test(`should return false when both numerator and denominator are zero`, () => {
42+
expect(isProperFraction(0, 0)).toEqual(false);
43+
});

0 commit comments

Comments
 (0)