|
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 | 5 |
|
7 | 6 | // Special case: numerator is zero |
8 | 7 | test(`should return false when denominator is zero`, () => { |
9 | | - expect(isProperFraction(1, 0)).toEqual(false); |
| 8 | + expect(isProperFraction(1,2 )).toEqual(true); |
| 9 | + expect(isProperFraction(2,1)).toEqual(false); |
| 10 | + expect(isProperFraction(5,5)).toEqual(false); |
| 11 | + expect(isProperFraction(0,5)).toEqual(true); |
| 12 | + expect(isProperFraction(5,0)).toEqual(false); |
| 13 | + expect(isProperFraction(0,0)).toEqual(false); |
| 14 | + expect(isProperFraction(-1,2)).toEqual(true); |
| 15 | + expect(isProperFraction(1,-2)).toEqual(false); |
| 16 | + expect(isProperFraction(-2,-1)).toEqual(true); |
| 17 | + expect(isProperFraction(-1,-2)).toEqual(false); |
| 18 | + expect(isProperFraction(0.5,1)).toEqual(true); |
| 19 | + expect(isProperFraction(1.5,1)).toEqual(false); |
| 20 | + expect(isProperFraction(Infinity,2)).toEqual(false); |
| 21 | + expect(isProperFraction(2,Infinity)).toEqual(false); |
| 22 | + expect(isProperFraction(NaN,2)).toEqual(false) |
| 23 | + expect(isProperFraction(2,NaN)).toEqual(false); |
| 24 | + expect(isProperFraction(999999999, 1000000000)).toEqual(true) |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
10 | 33 | }); |
0 commit comments