Skip to content

Commit 2fdc1ca

Browse files
committed
Completed 2-is-proper-fraction.test.js and modified function in 2-is-proper-fraction.js
1 parent b7ff208 commit 2fdc1ca

File tree

4 files changed

+3403
-2
lines changed

4 files changed

+3403
-2
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ function getAngleType(angle) {
2424
if (angle === 90) {
2525
return "Right angle";
2626
}
27-
if (angle < 90) {
27+
if (angle > 0 && angle < 90) {
2828
return "Acute angle";
2929
}
3030
if (angle > 90 && angle < 180) {
3131
return "Obtuse angle";
3232
}
33+
return "Invalid angle";
3334
// Run the tests, work out what Case 2 is testing, and implement the required code here.
3435
// Then keep going for the other cases, one at a time.
3536
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
if (numerator < denominator) {
14+
if (denominator === 0) {
15+
return false;
16+
} else if (Math.abs(numerator) < Math.abs(denominator)) {
1517
return true;
1618
} else {
1719
return false;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
test(`should return true for proper fraction with positive numerator and denominator`, () => {
13+
expect(isProperFraction(1, 2)).toEqual(true);
14+
});
15+
16+
test(`should return false for improper fraction with positive numerator and denominator`, () => {
17+
expect(isProperFraction(3, 2)).toEqual(false);
18+
});
19+
20+
test(`should return true for numerator zero and positive denominator`, () => {
21+
expect(isProperFraction(0, 5)).toEqual(true);
22+
});
23+
24+
test(`should return false for denominator zero`, () => {
25+
expect(isProperFraction(5, 0)).toEqual(false);
26+
});

0 commit comments

Comments
 (0)