Skip to content

Commit 958730d

Browse files
authored
testing code using jest
1 parent bf0a9bf commit 958730d

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

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(220)).toEqual("Reflex angle");
38+
});

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ test("should return true for a proper fraction", () => {
77
});
88

99
// Case 2: Identify Improper Fractions:
10+
test("should return folse for a improper fraction", () => {
11+
expect(isProperFraction(5, 2)).toEqual(false);
12+
});
1013

1114
// Case 3: Identify Negative Fractions:
15+
test("should return true for a negative fraction", () => {
16+
expect(isProperFraction(-4, 7)).toEqual(true);
17+
});
1218

1319
// Case 4: Identify Equal Numerator and Denominator:
20+
test("should return true for a equal fraction", () => {
21+
expect(isProperFraction(3, 3)).toEqual(true);
22+
});

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,35 @@ test("should return 11 for Ace of Spades", () => {
88
});
99

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return 3 for 3 of Clubs", () => {
12+
expect(getCardValue("3♣")).toEqual(3);
13+
});
14+
15+
test("should return 7 for 7 of Spades", () => {
16+
expect(getCardValue("7♠")).toEqual(7);
17+
});
18+
19+
test("should return 9 for 9 of Diamonds", () => {
20+
expect(getCardValue("9♦")).toEqual(9);
21+
});
22+
1123
// Case 3: Handle Face Cards (J, Q, K):
24+
test("should return 10 for Jack of Clubs", () => {
25+
expect(getCardValue("J♦")).toEqual(10);
26+
});
27+
28+
test("should return 10 for Queen of Spades", () => {
29+
expect(getCardValue("Q♣")).toEqual(10);
30+
});
31+
32+
test("should return 10 for King of Hearts", () => {
33+
expect(getCardValue("K♠")).toEqual(10);
34+
});
1235
// Case 4: Handle Ace (A):
36+
test("should return 11 for Ace of Diamonds", () => {
37+
expect(getCardValue("A♦")).toEqual(11);
38+
});
1339
// Case 5: Handle Invalid Cards:
40+
test("should return null for invalid card 'B'", () => {
41+
expect(getCardValue("Z♠")).toBeNull();
42+
});

0 commit comments

Comments
 (0)