Skip to content

Commit 0072576

Browse files
committed
Refactor angle type and proper fraction functions; enhance tests for accuracy and coverage
1 parent fe32f50 commit 0072576

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function getAngleType(angle) {
2929
} else {
3030
return "Invalid angle";
3131
}
32-
3332
}
3433

3534
// The line below allows us to load the getAngleType function into tests in other files.
@@ -69,5 +68,3 @@ assertEquals(reflex, "Reflex angle");
6968
// Example: Identify Invalid Angles
7069
const invalid = getAngleType(-45);
7170
assertEquals(invalid, "Invalid angle");
72-
73-

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
@@ -13,12 +13,12 @@
1313
function isProperFraction(numerator, denominator) {
1414
// TODO: Implement this function
1515
if (denominator === 0) {
16-
return false; // A fraction with a denominator of 0 is undefined, so it's not a proper fraction.
16+
return false;
1717
}
1818
if (Math.abs(numerator) < Math.abs(denominator)) {
19-
return true; // A proper fraction has an absolute value of the numerator less than the absolute value of the denominator.
19+
return true;
2020
}
21-
return false; // If none of the above conditions are met, it's not a proper fraction.
21+
return false;
2222
}
2323

2424
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -64,4 +64,4 @@ assertEquals(isProperFraction(1, 0), false);
6464
assertEquals(isProperFraction(-1, 0), false);
6565

6666
// Example: 0/0 is not a proper fraction (undefined)
67-
assertEquals(isProperFraction(0, 0), false);
67+
assertEquals(isProperFraction(0, 0), false);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
1111
expect(getAngleType(1)).toEqual("Acute angle");
1212
expect(getAngleType(45)).toEqual("Acute angle");
1313
expect(getAngleType(89)).toEqual("Acute angle");
14+
expect(getAngleType(89.9)).toBe("Acute angle");
1415
});
1516

1617
// Case 2: Right angle

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ test(`should return false when denominator is zero`, () => {
1111
expect(isProperFraction(0, 0)).toEqual(false);
1212
});
1313

14-
test(`should return true for valid proper fractions for negatives`, () => {
14+
test(`should return true for valid proper fractions for Positives and Negatives`, () => {
1515
expect(isProperFraction(1, 2)).toEqual(true);
1616
expect(isProperFraction(-1, 2)).toEqual(true);
1717
expect(isProperFraction(1, -2)).toEqual(true);
1818
expect(isProperFraction(-1, -2)).toEqual(true);
1919
});
2020

21-
test(`should return false when denominator is zero`, () => {
21+
test(`should return false for improper fraction`, () => {
2222
expect(isProperFraction(-1, 0)).toEqual(false);
23-
expect(isProperFraction(2, 1)).toBe(false);
24-
expect(isProperFraction(-2, 1)).toBe(false);
25-
expect(isProperFraction(2, 2)).toBe(false);
23+
expect(isProperFraction(2, 1)).toEqual(false);
24+
expect(isProperFraction(-2, 1)).toEqual(false);
25+
expect(isProperFraction(2, 2)).toEqual(false);
2626
});

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ test(`Should throw an error for invalid cards`, () => {
3434
expect(() => getCardValue("invalid")).toThrow();
3535
expect(() => getCardValue("AinvalidSuit")).toThrow();
3636
expect(() => getCardValue("InvalidRank♠")).toThrow();
37+
expect(() => getCardValue("A♤")).toThrow("Invalid card: Invalid suit");
38+
expect(() => getCardValue("11♠")).toThrow("Invalid card: Invalid rank");
3739
});
3840

3941
// Suggestion: Group the remaining test data into these categories:

0 commit comments

Comments
 (0)