|
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 | | -// Special case: numerator is zero |
6 | | -test(`should return true when the numerator is zero`, () => { |
| 5 | +// Special case: numerator equals zero |
| 6 | +test(`returns true if numerator equals zero`, () => { |
7 | 7 | expect(isProperFraction(0, 1)).toEqual(true); |
| 8 | + expect(isProperFraction(0, -2)).toEqual(true); |
8 | 9 | }); |
9 | 10 |
|
10 | | -test(`should return true when the denominator is bigger then the numerator` => { |
| 11 | +test(`returns true when abs(denominator) > abs(numerator)`, () => { |
11 | 12 | expect(isProperFraction(1, 2)).toEqual(true); |
| 13 | + expect(isProperFraction(-1, 2)).toEqual(true); |
| 14 | + expect(isProperFraction(-1, -2)).toEqual(true); |
| 15 | + expect(isProperFraction(0, 1)).toEqual(true); |
12 | 16 | }); |
13 | 17 |
|
14 | | -test(`should return false when the denominator is equal to the numerator`, () => { |
| 18 | +test(`returns false when denominator equals numerator`, () => { |
15 | 19 | expect(isProperFraction(2, 2)).toEqual(false); |
| 20 | + expect(isProperFraction(-2, -2)).toEqual(false); |
16 | 21 | }); |
17 | 22 |
|
18 | | -test(`should return false when the denominator is smaller than the numerator`, () => { |
| 23 | +test(`returns false when abs(denominator) < abs(numerator)`, () => { |
19 | 24 | expect(isProperFraction(2, 1)).toEqual(false); |
| 25 | + expect(isProperFraction(-2, 1)).toEqual(false); |
| 26 | + expect(isProperFraction(2, -1)).toEqual(false); |
| 27 | + expect(isProperFraction(-2, -1)).toEqual(false); |
20 | 28 | }); |
21 | 29 |
|
22 | | -test(`should return false when the denominator and the numerator are both zero`, () => { |
| 30 | +test(`returns false when 0/0`, () => { |
23 | 31 | expect(isProperFraction(0, 0)).toEqual(false); |
24 | 32 | }); |
25 | 33 |
|
26 | | -test(`should return false when the denominator is zero`, () => { |
| 34 | +test(`returns false when denominator equals 0`, () => { |
27 | 35 | expect(isProperFraction(1, 0)).toEqual(false); |
| 36 | + expect(isProperFraction(-1, 0)).toEqual(false); |
28 | 37 | }); |
0 commit comments