Skip to content

Commit 096f9b6

Browse files
committed
adding 5 tests and passing 5 tests for 1-get-angle-type
1 parent 7a2b0a1 commit 096f9b6

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@ function getAngleType(angle) {
1111
if (angle === 90) {
1212
return "Right angle";
1313
}
14-
// Run the tests, work out what Case 2 is testing, and implement the required code here.
15-
// Then keep going for the other cases, one at a time.
14+
// Run the tests, work out what Case 2 is testing, and implement the required code here.
15+
// Then keep going for the other cases, one at a time.
16+
if (angle < 90) {
17+
return "Acute angle";
18+
}
19+
if (angle > 90 && angle < 180) {
20+
return "Obtuse angle";
21+
}
22+
if (angle === 180) {
23+
return "Straight angle";
24+
}
25+
if (angle > 180 && angle < 360) {
26+
return "Reflex angle";
27+
}
1628
}
1729

1830
// The line below allows us to load the getAngleType function into tests in other files.
@@ -51,13 +63,18 @@ assertEquals(acute, "Acute angle");
5163
// Then the function should return "Obtuse angle"
5264
const obtuse = getAngleType(120);
5365
// ====> write your test here, and then add a line to pass the test in the function above
66+
assertEquals(obtuse, "Obtuse angle");
5467

5568
// Case 4: Identify Straight Angles:
5669
// When the angle is exactly 180 degrees,
5770
// Then the function should return "Straight angle"
5871
// ====> write your test here, and then add a line to pass the test in the function above
72+
const straight = getAngleType(180);
73+
assertEquals(straight, "Straight angle");
5974

6075
// Case 5: Identify Reflex Angles:
6176
// When the angle is greater than 180 degrees and less than 360 degrees,
6277
// 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
78+
// ====> write your test here, and then add a line to pass the test in the function above
79+
const reflex = getAngleType(250);
80+
assertEquals(reflex, "Reflex angle");

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,27 @@ test("should identify right angle (90°)", () => {
1212
// Case 2: Identify Acute Angles:
1313
// When the angle is less than 90 degrees,
1414
// Then the function should return "Acute angle"
15+
test("should identify acute angle (<90°)", () => {
16+
expect(getAngleType(45)).toEqual("Acute angle");
17+
});
1518

1619
// Case 3: Identify Obtuse Angles:
1720
// When the angle is greater than 90 degrees and less than 180 degrees,
1821
// Then the function should return "Obtuse angle"
22+
test("should identify obtuse angle (>90° and <180°)", () => {
23+
expect(getAngleType(120)).toEqual("Obtuse angle");
24+
});
1925

2026
// Case 4: Identify Straight Angles:
2127
// When the angle is exactly 180 degrees,
2228
// Then the function should return "Straight angle"
29+
test("should identify straight angle (180°)", () => {
30+
expect(getAngleType(180)).toEqual("Straight angle");
31+
});
2332

2433
// Case 5: Identify Reflex Angles:
2534
// When the angle is greater than 180 degrees and less than 360 degrees,
2635
// Then the function should return "Reflex angle"
36+
test("should identify reflex angle (>180° and <360°)", () => {
37+
expect(getAngleType(250)).toEqual("Reflex angle");
38+
});

0 commit comments

Comments
 (0)