Skip to content

Commit f9a510e

Browse files
committed
test: add assert casses to the helper to verify getAngleType logic and boundaries
1 parent 9d4fb3c commit f9a510e

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// execute the code to ensure all tests pass.
1616

1717
function getAngleType(angle) {
18-
if(angle < 90){
18+
if(angle > 0 && angle < 90){
1919
return "Acute angle";
2020
} else if (angle === 90){
2121
return "Right angle";
@@ -26,7 +26,7 @@ function getAngleType(angle) {
2626
} else if (angle > 180 && angle < 360){
2727
return "Reflex angle";
2828
}
29-
return "invalid angle";
29+
return "Invalid angle";
3030

3131
}
3232

@@ -37,14 +37,31 @@ module.exports = getAngleType;
3737
// This helper function is written to make our assertions easier to read.
3838
// If the actual output matches the target output, the test will pass
3939
function assertEquals(actualOutput, targetOutput) {
40+
4041
console.assert(
4142
actualOutput === targetOutput,
42-
`Expected ${actualOutput} to equal ${targetOutput}`
43+
`❌ Error: expected ${actualOutput} to equal ${targetOutput}`
4344
);
45+
46+
if (actualOutput === targetOutput) {
47+
console.log(`✅ Test passed: ${actualOutput} equals ${targetOutput}`);
48+
}
49+
4450
}
4551

4652
// TODO: Write tests to cover all cases, including boundary and invalid cases.
4753
// Example: Identify Right Angles
48-
const right = getAngleType(90);
54+
const right = getAngleType(45);
4955
assertEquals(right, "Right angle");
56+
const acute = getAngleType(45);
57+
assertEquals(acute, "Acute angle");
58+
const obtuse = getAngleType(180);
59+
assertEquals(obtuse, "Obtuse angle");
60+
const straight = getAngleType(180);
61+
assertEquals(straight, "Straight angle");
62+
const reflex = getAngleType(240);
63+
assertEquals(reflex, "Reflex angle");
64+
const invalid = getAngleType(-10);
65+
assertEquals(invalid, "Invalid angle");
66+
console.log("✓ All test executed!");
5067

0 commit comments

Comments
 (0)