|
| 1 | +// This statement loads the isProperFraction function you wrote in the implement directory. |
| 2 | +// We will use the same function, but write tests for it using Jest in this file. |
1 | 3 | const isProperFraction = require("../implement/2-is-proper-fraction"); |
2 | 4 |
|
3 | | -test("should return true when numerator is less than denominator", () => { |
4 | | - expect(isProperFraction(1, 2)).toEqual(true); |
5 | | - expect(isProperFraction(3, 4)).toEqual(true); |
6 | | -}); |
7 | | - |
8 | | -test("should return false when numerator is greater than denominator", () => { |
9 | | - expect(isProperFraction(5, 2)).toEqual(false); |
10 | | - expect(isProperFraction(10, 3)).toEqual(false); |
11 | | -}); |
12 | | - |
13 | | -test("should return false when numerator equals denominator", () => { |
14 | | - expect(isProperFraction(4, 4)).toEqual(false); |
15 | | -}); |
16 | | - |
17 | | -test("should return true when numerator is zero and denominator is positive", () => { |
18 | | - expect(isProperFraction(0, 5)).toEqual(true); |
19 | | -}); |
| 5 | +// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. |
20 | 6 |
|
21 | | -test("should return false when denominator is zero", () => { |
| 7 | +// Special case: numerator is zero |
| 8 | +test(`should return false when denominator is zero`, () => { |
22 | 9 | expect(isProperFraction(1, 0)).toEqual(false); |
23 | 10 | }); |
24 | | - |
25 | | -test("should return false when numerator and denominator are zero", () => { |
26 | | - expect(isProperFraction(0, 0)).toEqual(false); |
27 | | -}); |
28 | | - |
29 | | -test("should return true when numerator is negative and denominator is positive", () => { |
30 | | - expect(isProperFraction(-1, 6)).toEqual(true); |
31 | | -}); |
32 | | - |
33 | | -test("should return false when denominator is negative", () => { |
34 | | - expect(isProperFraction(1, -5)).toEqual(false); |
35 | | -}); |
36 | | - |
37 | | -test("should return false when both numerator and denominator are negative", () => { |
38 | | - expect(isProperFraction(-4, -5)).toEqual(false); |
39 | | -}); |
0 commit comments