Skip to content

Commit 98734bf

Browse files
author
Pretty Taruvinga
committed
refactor tests: use absolute value rule for proper fractions
1 parent f10a8d4 commit 98734bf

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,28 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

77
// Special case: denominator is zero
8-
test(`should return false when denominator is zero`, () => {
8+
test("should return false when denominator is zero", () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
1111

1212
// Case: numerator is zero
13-
test(`should return true when numerator is zero and denominator is positive`, () => {
13+
test("should return true when numerator is zero and denominator is positive", () => {
1414
expect(isProperFraction(0, 1)).toEqual(true);
1515
});
16-
test("should return true when numerator is smaller than denominator and both are positive", () => {
16+
17+
// Proper fractions
18+
test("should return true when abs(numerator) < abs(denominator)", () => {
1719
expect(isProperFraction(1, 2)).toEqual(true);
20+
expect(isProperFraction(-1, 2)).toEqual(true);
21+
expect(isProperFraction(1, -2)).toEqual(true);
22+
expect(isProperFraction(-1, -2)).toEqual(true);
1823
});
1924

25+
// Improper fractions
2026
test("should return false when numerator is equal to denominator", () => {
2127
expect(isProperFraction(2, 2)).toEqual(false);
2228
});
2329

2430
test("should return false when numerator is greater than denominator", () => {
2531
expect(isProperFraction(3, 2)).toEqual(false);
2632
});
27-
28-
test("should return false when numerator is negative", () => {
29-
expect(isProperFraction(-1, 2)).toEqual(false);
30-
});
31-
32-
test("should return true when both numerator and denominator are negative and numerator is smaller than denominator", () => {
33-
expect(isProperFraction(-1, -2)).toEqual(true);
34-
});

0 commit comments

Comments
 (0)