Skip to content

Commit 3a4fd15

Browse files
authored
Add tests for isProperFraction function
1 parent ea57d66 commit 3a4fd15

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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