-
-
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
43 lines (35 loc) · 1.42 KB
/
2-is-proper-fraction.test.js
File metadata and controls
43 lines (35 loc) · 1.42 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
38
39
40
41
42
43
// 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");
// denominator is zero
test("should return false when denominator is zero", () => {
expect(isProperFraction(1, 0)).toEqual(false);
});
// proper fraction (numerator < denominator)
test("should return true when numerator < denominator", () => {
expect(isProperFraction(1, 2)).toEqual(true);
});
// improper fraction (numerator > denominator)
test("should return false when numerator > denominator", () => {
expect(isProperFraction(5, 3)).toEqual(false);
});
// equal numbers
test("should return false when numerator === denominator", () => {
expect(isProperFraction(4, 4)).toEqual(false);
});
// numerator is zero
test("should return true when numerator is zero and denominator is positive", () => {
expect(isProperFraction(0, 5)).toEqual(true);
});
// negative numerator
test("should return false when numerator is negative", () => {
expect(isProperFraction(-2, 4)).toEqual(false);
});
// negative denominator
test("should return false when denominator is negative", () => {
expect(isProperFraction(5, -4)).toEqual(false);
});
// both negative
test("should return false when both numerator and denominator are negative", () => {
expect(isProperFraction(-3, -5)).toEqual(false);
});