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