Skip to content

Commit 3685fe5

Browse files
:wq
EnterEsc :wq EnterEsc :wq Esc :wq Enter :q! Enter
1 parent c7ddaed commit 3685fe5

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,33 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
1414
});
1515

1616
// Case 2: Right angle
17+
test('should return "Right angle" when angle is 90', () => {
18+
expect(getAngleType(90)).toEqual("Right angle");
19+
});
20+
1721
// Case 3: Obtuse angles
22+
test('should return "Obtuse angle" when (90 < angle < 180)', () => {
23+
expect(getAngleType(91)).toEqual("Obtuse angle");
24+
expect(getAngleType(120)).toEqual("Obtuse angle");
25+
expect(getAngleType(179)).toEqual("Obtuse angle");
26+
})
27+
1828
// Case 4: Straight angle
29+
test('should return "Straight angle" when angle is 180', () => {
30+
expect(getAngleType(180)).toEqual("Straight angle");
31+
})
32+
1933
// Case 5: Reflex angles
34+
test('should return "Reflex angle" when (180 < angle < 360)', () => {
35+
expect(getAngleType(181)).toEqual("Reflex angle");
36+
expect(getAngleType(270)).toEqual("Reflex angle");
37+
expect(getAngleType(359)).toEqual("Reflex angle");
38+
})
39+
2040
// Case 6: Invalid angles
41+
test('should return "Invalid angle" when angle is outside valid range', () => {
42+
expect(getAngleType(0)).toEqual("Invalid angle");
43+
expect(getAngleType(360)).toEqual("Invalid angle");
44+
expect(getAngleType(-10)).toEqual("Invalid angle");
45+
expect(getAngleType(720)).toEqual("Invalid angle");
46+
})

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,43 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
44

55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

7-
// Special case: numerator is zero
7+
// Special case: denominator is zero
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
// Numerator is zero
13+
test(`should return true when numerator is zero and denominator is non-zero`, () => {
14+
expect(isProperFraction(0, 1)).toEqual(true);
15+
});
16+
17+
//Proper fractions
18+
test("should return true for proper fractions", () => {
19+
expect(isProperFraction(1,2)).toEqual(true);
20+
expect(isProperFraction(2,5)).toEqual(true);
21+
})
22+
23+
//Equal Numerator and Denominator
24+
test("should return false when numerator equals denominator", () => {
25+
expect(isProperFraction(2,2)).toEqual(false);
26+
})
27+
28+
//Improper fractions
29+
test("should return false for improper fractions", () => {
30+
expect(isProperFraction(5,3)).toEqual(false);
31+
})
32+
33+
//Negative numerator
34+
test("should return true when numerator is negative but absolute value is smaller", () => {
35+
expect(isProperFraction(-1, 3)).toEqual(true);
36+
})
37+
38+
//Negative denominator
39+
test("should return true when denominator is negative but absolute value is larger", () => {
40+
expect(isProperFraction(1, -3)).toEqual(true);
41+
})
42+
43+
//Both Negative
44+
test("should return true when both numerator and denominator are negative and proper", () => {
45+
expect(isProperFraction(-2, -5)).toEqual(true);
46+
})

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,37 @@ test(`Should return 11 when given an ace card`, () => {
99
expect(getCardValue("A♠")).toEqual(11);
1010
});
1111

12+
// Case 2: Number Cards
13+
test("should return correct numeric value for number cards", () => {
14+
expect(getCardValue("2♠")).toEqual(2);
15+
expect(getCardValue("7♦")).toEqual(7);
16+
expect(getCardValue("10♣")).toEqual(10);
17+
})
18+
19+
// Case 3: Face Cards
20+
test("should return 10 for face cards", () => {
21+
expect(getCardValue("J♠")).toEqual(10);
22+
expect(getCardValue("Q♥")).toEqual(10);
23+
expect(getCardValue("K♦")).toEqual(10);
24+
})
25+
26+
// Case 4: Invalid Cards
27+
test("should throw error for invalid suit", () => {
28+
expect(() => getCardValue("A?")).toThrow();
29+
})
30+
31+
test("should throw error for invalid rank", () => {
32+
expect(() => getCardValue("1♠")).toThrow();
33+
});
34+
35+
test("should throw error for missing suit", () => {
36+
expect(() => getCardValue("A")).toThrow();
37+
});
38+
39+
test("should throw error for completely invalid string", () => {
40+
expect(() => getCardValue("invalid")).toThrow();
41+
});
42+
1243
// Suggestion: Group the remaining test data into these categories:
1344
// Number Cards (2-10)
1445
// Face Cards (J, Q, K)

0 commit comments

Comments
 (0)