Skip to content

Commit d83c685

Browse files
committed
updated 2-is-proper-function-test.js to make test description clearer also formatted with Prettier
1 parent 8234f45 commit d83c685

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
// After you have implemented the function, write tests to cover all the cases, and
1111
// execute the code to ensure all tests pass.
1212

13-
function isProperFraction(numerator, denominator) {
13+
function isProperFraction(numerator, denominator) {
1414
// Denominator cannot be 0 because it won't make a fraction.
15-
if (denominator === 0) {
16-
return false;
17-
}
18-
// Compare absolute values to eliminate negative values
19-
//Proper fraction = absolute value of numerator < absolute value of denominator
20-
return Math.abs(numerator) < Math.abs(denominator);
15+
if (denominator === 0) {
16+
return false;
17+
}
18+
// Compare absolute values to eliminate negative values
19+
//Proper fraction = absolute value of numerator < absolute value of denominator
20+
return Math.abs(numerator) < Math.abs(denominator);
2121
}
2222

2323
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -36,7 +36,7 @@ function assertEquals(actualOutput, targetOutput) {
3636
// What combinations of numerators and denominators should you test?
3737

3838
// Example: 1/2 is a proper fraction
39-
assertEquals(isProperFraction(1, 2), true);
39+
assertEquals(isProperFraction(1, 0), false);
4040
assertEquals(isProperFraction(2, 1), false);
41+
assertEquals(isProperFraction(1, 2), true);
4142
assertEquals(isProperFraction(-1, -2), true);
42-
assertEquals(isProperFraction(1, 0), false);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
1111

12-
test(`should return true when denominator is greater than numerator (2)`, () => {
13-
expect(isProperFraction(1, 2)).toEqual(true);
12+
test("should return false when absolute numerator is greater than or equal to absolute denominator", () => {
13+
expect(isProperFraction(2, 1)).toEqual(false);
1414
});
1515

16-
test(`should return false when denominator is smaller than the numerator (1)`, () => {
17-
expect(isProperFraction(2, 1)).toEqual(false);
16+
test("should return true when absolute numerator is less than absolute denominator", () => {
17+
expect(isProperFraction(1, 2)).toEqual(true);
1818
});
1919

20-
test(`should return true when both values are valid numbers`, () => {
20+
test("should correctly handle negative numbers using absolute values", () => {
2121
expect(isProperFraction(-1, -2)).toEqual(true);
22-
});
22+
});

0 commit comments

Comments
 (0)