Skip to content

Commit f34d033

Browse files
committed
Practice Writing tests
1 parent 8f3d6cf commit f34d033

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@
88
// Then, write the next test! :) Go through this process until all the cases are implemented
99

1010
function getAngleType(angle) {
11-
if (angle === 90) {
11+
if (angle === 90) {
1212
return "Right angle";
13+
} else if (angle < 90) {
14+
return "Acute angle";
15+
} else if (angle > 90 && angle < 180) {
16+
return "Obtuse angle";
17+
} else if (angle === 180) {
18+
return "Straight angle";
19+
} else if (angle > 180 && angle < 360) {
20+
return "Reflex angle";
21+
} else {
22+
return "Invalid angle";
1323
}
24+
}
1425
// Run the tests, work out what Case 2 is testing, and implement the required code here.
1526
// Then keep going for the other cases, one at a time.
16-
}
1727

1828
// The line below allows us to load the getAngleType function into tests in other files.
1929
// This will be useful in the "rewrite tests with jest" step.
@@ -50,14 +60,17 @@ assertEquals(acute, "Acute angle");
5060
// When the angle is greater than 90 degrees and less than 180 degrees,
5161
// Then the function should return "Obtuse angle"
5262
const obtuse = getAngleType(120);
53-
// ====> write your test here, and then add a line to pass the test in the function above
63+
assertEquals( obtuse, "Obtuse angle")
5464

5565
// Case 4: Identify Straight Angles:
5666
// When the angle is exactly 180 degrees,
67+
const straight = getAngleType(180)
68+
assertEquals (straight, "Straight angle");
5769
// Then the function should return "Straight angle"
58-
// ====> write your test here, and then add a line to pass the test in the function above
70+
5971

6072
// Case 5: Identify Reflex Angles:
6173
// When the angle is greater than 180 degrees and less than 360 degrees,
6274
// Then the function should return "Reflex angle"
63-
// ====> write your test here, and then add a line to pass the test in the function above
75+
const reflex= getAngleType( 350);
76+
assertEquals (reflex, "Reflex angle");

0 commit comments

Comments
 (0)