Skip to content

Commit 2e49fad

Browse files
committed
Write test for getAngleType
1 parent 5abf1f5 commit 2e49fad

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,31 @@
1515
// execute the code to ensure all tests pass.
1616

1717
function getAngleType(angle) {
18-
// TODO: Implement this function
18+
if (angle <= 0 || angle >= 360) return "invalid angle";
1919
}
2020

21+
if (angle < 90) {
22+
return "acute angle";
23+
}
24+
25+
if (angle === 90) {
26+
return "right angle";
27+
}
28+
29+
if (angle < 180) {
30+
return "obtuse angle";
31+
}
32+
33+
if (angle === 180) {
34+
return " straight angle";
35+
}
36+
37+
if (angle < 360) {
38+
return "reflext angle";
39+
}
40+
41+
// TODO: Implement this function
42+
2143
// The line below allows us to load the getAngleType function into tests in other files.
2244
// This will be useful in the "rewrite tests with jest" step.
2345
module.exports = getAngleType;
@@ -30,6 +52,13 @@ function assertEquals(actualOutput, targetOutput) {
3052
`Expected ${actualOutput} to equal ${targetOutput}`
3153
);
3254
}
55+
// Test
56+
assertEquals(getAngleType(45), "Acute angle");
57+
assertEquals(getAngleType(90), "Right angle");
58+
assertEquals(getAngleType(120), "Obtuse angle");
59+
assertEquals(getAngleType(180), "Straight angle");
60+
assertEquals(getAngleType(270), "Reflex angle");
61+
assertEquals(getAngleType(390), "invalid angle");
3362

3463
// TODO: Write tests to cover all cases, including boundary and invalid cases.
3564
// Example: Identify Right Angles

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"keywords": [],
1010
"author": "Code Your Future",
1111
"license": "ISC",
12-
"dependencies": {
13-
"jest": "^29.7.0"
12+
"devDependencies": {
13+
"jest": "^30.3.0"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)