Skip to content

Commit 9c67445

Browse files
committed
Update tests for isProperFraction to include negative fractions in validation
1 parent 8a26524 commit 9c67445

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const isProperFraction = require("../implement/2-is-proper-fraction");
44

5-
test("should return true for a proper fraction", () => {
5+
test("should return true for a proper fraction, including negatives", () => {
66
expect(isProperFraction(2, 3)).toEqual(true);
7+
expect(isProperFraction(-2, 3)).toEqual(true);
78
expect(isProperFraction(4, -5)).toEqual(true);
9+
expect(isProperFraction(-4, -5)).toEqual(true);
810
});
911

1012
// Case 2: Identify Improper Fractions:
11-
test("should return false for an improper fraction", () => {
12-
expect(isProperFraction(5, 4)).toEqual(false);
13+
test("should return false for an improper fraction, including negatives", () => {
14+
expect(isProperFraction(5, 4)).toEqual(false); // numerator greater than denominator
15+
expect(isProperFraction(5, -4)).toEqual(false); // negative denominator
16+
expect(isProperFraction(-5, 4)).toEqual(false); // negative numerator
17+
expect(isProperFraction(-5, -4)).toEqual(false); // both negative
1318
});
1419

1520
// Case 3: Identify Negative Fractions:

0 commit comments

Comments
 (0)