Skip to content

Commit 7c92cdc

Browse files
author
cjyuan
committed
Updated 1-implement/rewrite-tests-with-jest
1 parent 3e9bea5 commit 7c92cdc

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const getAngleType = require("../implement/1-get-angle-type");
44

5-
test("should identify right angle (90°)", () => {
6-
expect(getAngleType(90)).toEqual("Right angle");
7-
});
8-
9-
// REPLACE the comments with the tests
10-
// make your test descriptions as clear and readable as possible
5+
// TODO: Write tests in Jest syntax to cover all cases/outcomes,
6+
// including boundary and invalid cases.
117

12-
// Case 2: Identify Acute Angles:
13-
// When the angle is less than 90 degrees,
14-
// Then the function should return "Acute angle"
15-
16-
// Case 3: Identify Obtuse Angles:
17-
// When the angle is greater than 90 degrees and less than 180 degrees,
18-
// Then the function should return "Obtuse angle"
8+
// Case 1: Acute angles
9+
test(`should return "Acute angle" when (0 < angle < 90)`, () => {
10+
// Test various acute angles, including boundary cases
11+
expect(getAngleType(1)).toEqual("Acute angle");
12+
expect(getAngleType(45)).toEqual("Acute angle");
13+
expect(getAngleType(89)).toEqual("Acute angle");
14+
});
1915

20-
// Case 4: Identify Straight Angles:
21-
// When the angle is exactly 180 degrees,
22-
// Then the function should return "Straight angle"
2316

24-
// Case 5: Identify Reflex Angles:
25-
// When the angle is greater than 180 degrees and less than 360 degrees,
26-
// Then the function should return "Reflex angle"
17+
// Case 2: Right angle
18+
// Case 3: Obtuse angles
19+
// Case 4: Straight angle
20+
// Case 5: Reflex angles
21+
// Case 6: Invalid angles

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const isProperFraction = require("../implement/2-is-proper-fraction");
44

5-
test("should return true for a proper fraction", () => {
6-
expect(isProperFraction(2, 3)).toEqual(true);
7-
});
5+
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, and zeros.
86

9-
// Case 2: Identify Improper Fractions:
10-
11-
// Case 3: Identify Negative Fractions:
12-
13-
// Case 4: Identify Equal Numerator and Denominator:
7+
// Special case: numerator is zero
8+
test(`should return false when denominator is zero`, () => {
9+
expect(isProperFraction(1,0)).toEqual(false);
10+
});

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const getCardValue = require("../implement/3-get-card-value");
44

5-
test("should return 11 for Ace of Spades", () => {
6-
const aceofSpades = getCardValue("A♠");
7-
expect(aceofSpades).toEqual(11);
5+
// TODO: Write tests in Jest syntax to cover all possible outcomes.
6+
7+
// Case 1: Ace (A)
8+
test(`Should return 11 when given an ace card`, () => {
9+
expect(getCardValue('A♠')).toEqual(11);
810
});
911

10-
// Case 2: Handle Number Cards (2-10):
11-
// Case 3: Handle Face Cards (J, Q, K):
12-
// Case 4: Handle Ace (A):
13-
// Case 5: Handle Invalid Cards:
12+
// Suggestion: Group the remaining test data into these categories:
13+
// Number Cards (2-10)
14+
// Face Cards (J, Q, K)
15+
// Invalid Cards
16+
17+
// To find out how to test if a function throws an error as expected in Jest, please refer to the
18+
// Jest documentation: https://jestjs.io/docs/expect#tothrowerror
19+

0 commit comments

Comments
 (0)