-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path2-is-proper-fraction.test.js
More file actions
37 lines (31 loc) · 1.37 KB
/
2-is-proper-fraction.test.js
File metadata and controls
37 lines (31 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// This statement loads the isProperFraction function you wrote in the implement directory.
// We will use the same function, but write tests for it using Jest in this file.
const isProperFraction = require("../implement/2-is-proper-fraction");
// Special case: numerator equals zero
test(`returns true if numerator equals zero`, () => {
expect(isProperFraction(0, 1)).toEqual(true);
expect(isProperFraction(0, -2)).toEqual(true);
});
test(`returns true when abs(denominator) > abs(numerator)`, () => {
expect(isProperFraction(1, 2)).toEqual(true);
expect(isProperFraction(-1, 2)).toEqual(true);
expect(isProperFraction(-1, -2)).toEqual(true);
expect(isProperFraction(0, 1)).toEqual(true);
});
test(`returns false when denominator equals numerator`, () => {
expect(isProperFraction(2, 2)).toEqual(false);
expect(isProperFraction(-2, -2)).toEqual(false);
});
test(`returns false when abs(denominator) < abs(numerator)`, () => {
expect(isProperFraction(2, 1)).toEqual(false);
expect(isProperFraction(-2, 1)).toEqual(false);
expect(isProperFraction(2, -1)).toEqual(false);
expect(isProperFraction(-2, -1)).toEqual(false);
});
test(`returns false when 0/0`, () => {
expect(isProperFraction(0, 0)).toEqual(false);
});
test(`returns false when denominator equals 0`, () => {
expect(isProperFraction(1, 0)).toEqual(false);
expect(isProperFraction(-1, 0)).toEqual(false);
});