Skip to content

Commit c4f94e6

Browse files
committed
reimplemented the tests for the function change in proper fraction.
1 parent 48814ec commit c4f94e6

1 file changed

Lines changed: 46 additions & 31 deletions

File tree

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

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,51 @@
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+
// Proper fraction
6+
test("should return true when the denominator is greater than the numerator", () => {
7+
expect(isProperFraction(1, 2)).toBe(true);
8+
});
9+
10+
// Improper fraction
11+
test("should return false when the numerator is greater than the denominator", () => {
12+
expect(isProperFraction(2, 1)).toBe(false);
13+
});
14+
15+
// Zero numerator
16+
test("should return true when the numerator is zero", () => {
17+
expect(isProperFraction(0, 5)).toBe(true);
18+
});
19+
20+
// Zero denominator
21+
test("should return false when the denominator is zero", () => {
22+
expect(isProperFraction(5, 0)).toBe(false);
23+
});
24+
25+
// numerator equals denominator
26+
test("should return false when numerator equals denominator ", () => {
27+
expect(isProperFraction(5, 5)).toBe(false);
28+
});
29+
30+
// Both numerator and denominator are zero
31+
test("should return false when both the numerator and denominator are zero", () => {
32+
expect(isProperFraction(0, 0)).toBe(false);
33+
});
34+
35+
// Negative numbers
36+
test("should correctly identify proper fractions when given negative numbers", () => {
37+
expect(isProperFraction(-1, 2)).toBe(true);
38+
expect(isProperFraction(1, -2)).toBe(true);
39+
expect(isProperFraction(-1, -2)).toBe(true);
40+
expect(isProperFraction(-2, -1)).toBe(false);
41+
});
42+
43+
// Decimal numbers
44+
test("should correctly identify proper fractions when given decimal numbers", () => {
45+
expect(isProperFraction(0.5, 1)).toBe(true);
46+
expect(isProperFraction(1.5, 1)).toBe(false);
47+
});
548

6-
test("should correctly identify proper fractions", () => {
7-
// Whole number fractions
8-
expect(isProperFraction(1, 2)).toEqual(true);
9-
expect(isProperFraction(2, 1)).toEqual(false);
10-
expect(isProperFraction(5, 5)).toEqual(false);
11-
12-
// Zero
13-
expect(isProperFraction(0, 5)).toEqual(true);
14-
expect(isProperFraction(5, 0)).toEqual(false);
15-
expect(isProperFraction(0, 0)).toEqual(false);
16-
17-
// Negative numbers
18-
expect(isProperFraction(-1, 2)).toEqual(true);
19-
expect(isProperFraction(1, -2)).toEqual(false);
20-
expect(isProperFraction(-2, -1)).toEqual(true);
21-
expect(isProperFraction(-1, -2)).toEqual(false);
22-
23-
// Decimal numbers
24-
expect(isProperFraction(0.5, 1)).toEqual(true);
25-
expect(isProperFraction(1.5, 1)).toEqual(false);
26-
27-
// Infinity
28-
expect(isProperFraction(Infinity, 2)).toEqual(false);
29-
expect(isProperFraction(2, Infinity)).toEqual(false);
30-
31-
// NaN
32-
expect(isProperFraction(NaN, 2)).toEqual(false);
33-
expect(isProperFraction(2, NaN)).toEqual(false);
34-
35-
// Large numbers
36-
expect(isProperFraction(999999999, 1000000000)).toEqual(true);
49+
// Large numbers
50+
test("should correctly identify proper fractions when given very large numbers", () => {
51+
expect(isProperFraction(999999999, 1000000000)).toBe(true);
3752
});

0 commit comments

Comments
 (0)