|
2 | 2 | // We will use the same function, but write tests for it using Jest in this file. |
3 | 3 | const isProperFraction = require("../implement/2-is-proper-fraction"); |
4 | 4 |
|
5 | | -test("should return true for a proper fraction", () => { |
| 5 | +test("should return true for a proper fraction (numerator < denominator)", () => { |
6 | 6 | expect(isProperFraction(2, 3)).toEqual(true); |
7 | 7 | }); |
8 | 8 |
|
9 | 9 | // Case 2: Identify Improper Fractions: |
10 | | - |
| 10 | +test("should return false for an improper fraction (numerator > denominator)", () => { |
| 11 | + expect(isProperFraction(5, 3)).toEqual(false); |
| 12 | +}); |
11 | 13 | // Case 3: Identify Negative Fractions: |
12 | | - |
| 14 | +test("should return true for a negative proper fraction", () => { |
| 15 | + expect(isProperFraction(-1, 4)).toEqual(true); |
| 16 | + expect(isProperFraction(1, -4)).toEqual(true); |
| 17 | + expect(isProperFraction(-1, -4)).toEqual(true); |
| 18 | +}); |
| 19 | +test("should return false for a negative improper fraction", () => { |
| 20 | + expect(isProperFraction(4, -3)).toEqual(false); |
| 21 | + expect(isProperFraction(5, -4)).toEqual(false); |
| 22 | + expect(isProperFraction(-5, 4)).toEqual(false); |
| 23 | +}); |
13 | 24 | // Case 4: Identify Equal Numerator and Denominator: |
| 25 | +test("should return false when numerator and denominator are equal", () => { |
| 26 | + expect(isProperFraction(5, 5)).toEqual(false); |
| 27 | +}); |
0 commit comments