Skip to content

Commit c83572d

Browse files
Complete fraction jest tests
1 parent 585816a commit c83572d

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
import { isProperFraction } from "../implement/2-is-proper-fraction.js";
22

33
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
4-
test(`should return true for proper fractions`, () => {
4+
test("should return true for proper fractions", () => {
55
expect(isProperFraction(1, 2)).toEqual(true);
66
expect(isProperFraction(2, 5)).toEqual(true);
77
});
88

9-
test(`should return false when numerator is not smaller`, () => {
9+
test("should return false when numerator is not smaller", () => {
1010
expect(isProperFraction(5, 5)).toEqual(false);
1111
expect(isProperFraction(7, 5)).toEqual(false);
1212
});
1313

14-
// Special case: numerator is zero
15-
test(`should return false when denominator is zero`, () => {
14+
test("should return false when denominator is zero", () => {
1615
expect(isProperFraction(1, 0)).toEqual(false);
16+
expect(isProperFraction(0, 0)).toEqual(false);
1717
});
1818

19-
test(`should return true when numerator is zero`, () => {
19+
test("should return true when numerator is zero", () => {
2020
expect(isProperFraction(0, 5)).toEqual(true);
2121
});
22+
23+
test("should handle negative numerators", () => {
24+
expect(isProperFraction(-2, 5)).toEqual(true);
25+
expect(isProperFraction(-5, 2)).toEqual(false);
26+
});
27+
28+
test("should handle negative denominators", () => {
29+
expect(isProperFraction(2, -5)).toEqual(true);
30+
expect(isProperFraction(5, -2)).toEqual(false);
31+
});
32+
33+
test("should handle negative numerators and denominators", () => {
34+
expect(isProperFraction(-2, -5)).toEqual(true);
35+
expect(isProperFraction(-5, -2)).toEqual(false);
36+
});

0 commit comments

Comments
 (0)