Skip to content

Commit 9d68b4e

Browse files
I re-edited the finction and tests to match and run the test on node and it passed
1 parent 7adde95 commit 9d68b4e

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
if (denominator === 0) return false;
14+
if (denominator <= 0) return false;
15+
if (numerator < 0) return false;
1516

16-
return Math.abs(numerator) < Math.abs(denominator);
17+
return numerator < denominator;
1718
}
18-
1919
// TODO: Implement this function
2020

2121
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -26,7 +26,7 @@ module.exports = isProperFraction;
2626
function assertEquals(actualOutput, targetOutput) {
2727
console.assert(
2828
actualOutput === targetOutput,
29-
`Expected ${actualOutput} to equal ${targetOutput}`
29+
`Expected ${actualOutput} toBe ${targetOutput}`
3030
);
3131
}
3232

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
// This statement loads the isProperFraction function you wrote in the implement directory.
2-
// We will use the same function, but write tests for it using Jest in this file.
31
const isProperFraction = require("../implement/2-is-proper-fraction");
42

53
// denominator is zero
64
test("should return false when denominator is zero", () => {
7-
expect(isProperFraction(1, 0)).toEqual(false);
5+
expect(isProperFraction(1, 0)).toBe(false);
86
});
97

10-
// proper fraction (numerator < denominator)
8+
// proper fraction
119
test("should return true when numerator < denominator", () => {
12-
expect(isProperFraction(1, 2)).toEqual(true);
10+
expect(isProperFraction(1, 2)).toBe(true);
1311
});
1412

15-
// improper fraction (numerator > denominator)
13+
// improper fraction
1614
test("should return false when numerator > denominator", () => {
17-
expect(isProperFraction(5, 3)).toEqual(false);
15+
expect(isProperFraction(5, 3)).toBe(false);
1816
});
1917

2018
// equal numbers
2119
test("should return false when numerator === denominator", () => {
22-
expect(isProperFraction(4, 4)).toEqual(false);
20+
expect(isProperFraction(4, 4)).toBe(false);
2321
});
2422

2523
// numerator is zero
2624
test("should return true when numerator is zero and denominator is positive", () => {
27-
expect(isProperFraction(0, 5)).toEqual(true);
25+
expect(isProperFraction(0, 5)).toBe(true);
2826
});
2927

3028
// negative numerator
3129
test("should return false when numerator is negative", () => {
32-
expect(isProperFraction(-2, 4)).toEqual(false);
30+
expect(isProperFraction(-2, 4)).toBe(false);
3331
});
3432

3533
// negative denominator
3634
test("should return false when denominator is negative", () => {
37-
expect(isProperFraction(5, -4)).toEqual(false);
35+
expect(isProperFraction(5, -4)).toBe(false);
3836
});
3937

4038
// both negative
4139
test("should return false when both numerator and denominator are negative", () => {
42-
expect(isProperFraction(-3, -5)).toEqual(false);
40+
expect(isProperFraction(-3, -5)).toBe(false);
4341
});

0 commit comments

Comments
 (0)