Skip to content

Commit c6f70e8

Browse files
committed
wrong sprint changes reverted
1 parent 2e62748 commit c6f70e8

File tree

6 files changed

+4
-179
lines changed

6 files changed

+4
-179
lines changed

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

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
// execute the code to ensure all tests pass.
1616

1717
function getAngleType(angle) {
18-
if (angle === 90) return "Right angle";
19-
if (angle === 180) return "Straight angle";
20-
if (angle > 0 && angle < 90) return "Acute angle";
21-
if (angle > 90 && angle < 180) return "Obtuse angle";
22-
if (angle > 180 && angle < 360) return "Reflex angle";
23-
24-
return "Invalid angle";
18+
// TODO: Implement this function
2519
}
2620

2721
// The line below allows us to load the getAngleType function into tests in other files.
@@ -41,24 +35,3 @@ function assertEquals(actualOutput, targetOutput) {
4135
// Example: Identify Right Angles
4236
const right = getAngleType(90);
4337
assertEquals(right, "Right angle");
44-
45-
const acute = getAngleType(50);
46-
assertEquals(acute, "Acute angle");
47-
48-
const obtuse = getAngleType(130);
49-
assertEquals(obtuse, "Obtuse angle");
50-
51-
const straight = getAngleType(180);
52-
assertEquals(straight, "Straight angle");
53-
54-
const reflex = getAngleType(225);
55-
assertEquals(reflex, "Reflex angle");
56-
57-
const invalidZero = getAngleType(0);
58-
assertEquals(invalidZero, "Invalid angle");
59-
60-
const invalidNegative = getAngleType(-45);
61-
assertEquals(invalidNegative, "Invalid angle");
62-
63-
const invalidOver = getAngleType(361);
64-
assertEquals(invalidOver, "Invalid angle");

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
return numerator > 0 && denominator > 0 && numerator < denominator;
14+
// TODO: Implement this function
1515
}
1616

1717
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -28,23 +28,6 @@ function assertEquals(actualOutput, targetOutput) {
2828

2929
// TODO: Write tests to cover all cases.
3030
// What combinations of numerators and denominators should you test?
31-
const properFraction = isProperFraction(2, 3);
32-
assertEquals(properFraction, true);
3331

3432
// Example: 1/2 is a proper fraction
3533
assertEquals(isProperFraction(1, 2), true);
36-
37-
const improperFraction = isProperFraction(5, 2);
38-
assertEquals(improperFraction, false);
39-
40-
const negativeFraction = isProperFraction(-4, 7);
41-
assertEquals(negativeFraction, true);
42-
43-
const equalFraction = isProperFraction(3, 3);
44-
assertEquals(equalFraction, false);
45-
46-
const zeroNumerator = isProperFraction(0, 5);
47-
assertEquals(zeroNumerator, true);
48-
49-
const zeroDenominator = isProperFraction(5, 0);
50-
assertEquals(zeroDenominator, false);

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

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,7 @@
2222
// execute the code to ensure all tests pass.
2323

2424
function getCardValue(card) {
25-
const validRanks = [
26-
"A",
27-
"2",
28-
"3",
29-
"4",
30-
"5",
31-
"6",
32-
"7",
33-
"8",
34-
"9",
35-
"10",
36-
"J",
37-
"Q",
38-
"K",
39-
];
40-
const validSuits = ["♠", "♥", "♦", "♣"];
41-
42-
// Extract rank and suit
43-
const suit = card.slice(-1);
44-
const rank = card.slice(0, -1);
45-
46-
// Validate suit
47-
if (!validSuits.includes(suit)) {
48-
throw new Error("Invalid card: invalid suit");
49-
}
50-
51-
// Validate rank
52-
if (!validRanks.includes(rank)) {
53-
throw new Error("Invalid card: invalid rank");
54-
}
55-
56-
// Return the card value
57-
if (rank === "A") {
58-
return 11;
59-
} else if (["J", "Q", "K"].includes(rank)) {
60-
return 10;
61-
} else {
62-
return parseInt(rank);
63-
}
25+
// TODO: Implement this function
6426
}
6527

6628
// The line below allows us to load the getCardValue function into tests in other files.
@@ -78,9 +40,6 @@ function assertEquals(actualOutput, targetOutput) {
7840
// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
7941
// Examples:
8042
assertEquals(getCardValue("9♠"), 9);
81-
assertEquals(getCardValue("5♥"), 5);
82-
assertEquals(getCardValue("K♦"), 10);
83-
assertEquals(getCardValue("A♣"), 11);
8443

8544
// Handling invalid cards
8645
try {
@@ -91,17 +50,3 @@ try {
9150
} catch (e) {}
9251

9352
// What other invalid card cases can you think of?
94-
95-
try {
96-
getCardValue("1♠");
97-
console.error("Error was not thrown for invalid card rank");
98-
} catch (error) {
99-
assertEquals(error.message, "Invalid card rank");
100-
}
101-
102-
try {
103-
getCardValue("5X");
104-
console.error("Error was not thrown for invalid card suit");
105-
} catch (error) {
106-
assertEquals(error.message, "Invalid card suit");
107-
}

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

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,12 @@ const getAngleType = require("../implement/1-get-angle-type");
99
test(`should return "Acute angle" when (0 < angle < 90)`, () => {
1010
// Test various acute angles, including boundary cases
1111
expect(getAngleType(1)).toEqual("Acute angle");
12-
expect(getAngleType(50)).toEqual("Acute angle");
12+
expect(getAngleType(45)).toEqual("Acute angle");
1313
expect(getAngleType(89)).toEqual("Acute angle");
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-
2117
// Case 3: Obtuse angles
22-
test(`should return "Obtuse angle" when (90 < angle < 180)`, () => {
23-
expect(getAngleType(91)).toEqual("Obtuse angle");
24-
expect(getAngleType(130)).toEqual("Obtuse angle");
25-
expect(getAngleType(179)).toEqual("Obtuse angle");
26-
});
27-
2818
// Case 4: Straight angle
29-
test(`should return "Straight angle" when angle is 180`, () => {
30-
expect(getAngleType(180)).toEqual("Straight angle");
31-
});
32-
3319
// Case 5: Reflex angles
34-
test(`should return "Reflex angle" when (180 < angle < 360)`, () => {
35-
expect(getAngleType(181)).toEqual("Reflex angle");
36-
expect(getAngleType(225)).toEqual("Reflex angle");
37-
expect(getAngleType(359)).toEqual("Reflex angle");
38-
});
39-
4020
// Case 6: Invalid angles
41-
test(`should return "Invalid angle" when angle is <= 0 or >= 360`, () => {
42-
expect(getAngleType(0)).toEqual("Invalid angle");
43-
expect(getAngleType(-45)).toEqual("Invalid angle");
44-
expect(getAngleType(361)).toEqual("Invalid angle");
45-
});

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,4 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
77
// Special case: numerator is zero
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
10-
expect(isProperFraction(-5, 0)).toEqual(false);
11-
});
12-
13-
test(`should return true for positive proper fractions`, () => {
14-
expect(isProperFraction(1, 2)).toEqual(true);
15-
expect(isProperFraction(2, 5)).toEqual(true);
16-
});
17-
18-
test(`should return false for positive improper fractions or equal values`, () => {
19-
expect(isProperFraction(3, 2)).toEqual(false);
20-
expect(isProperFraction(5, 5)).toEqual(false);
21-
});
22-
23-
test(`should return true when numerator is zero`, () => {
24-
expect(isProperFraction(0, 5)).toEqual(true);
25-
expect(isProperFraction(0, -5)).toEqual(true);
26-
});
27-
28-
test(`should evaluate correctly with various negative number combinations`, () => {
29-
expect(isProperFraction(-1, 2)).toEqual(true);
30-
expect(isProperFraction(1, -2)).toEqual(true);
31-
expect(isProperFraction(-1, -2)).toEqual(true);
32-
expect(isProperFraction(-5, 2)).toEqual(false);
33-
expect(isProperFraction(5, -2)).toEqual(false);
3410
});

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,13 @@ const getCardValue = require("../implement/3-get-card-value");
77
// Case 1: Ace (A)
88
test(`Should return 11 when given an ace card`, () => {
99
expect(getCardValue("A♠")).toEqual(11);
10-
expect(getCardValue("A♥")).toEqual(11);
1110
});
1211

1312
// Suggestion: Group the remaining test data into these categories:
1413
// Number Cards (2-10)
1514
// Face Cards (J, Q, K)
1615
// Invalid Cards
1716

18-
test(`Should return the correct numeric value for number cards`, () => {
19-
expect(getCardValue("2♣")).toEqual(2);
20-
expect(getCardValue("7♥")).toEqual(7);
21-
expect(getCardValue("10♦")).toEqual(10);
22-
});
23-
24-
test(`Should return 10 for face cards (J, Q, K)`, () => {
25-
expect(getCardValue("J♠")).toEqual(10);
26-
expect(getCardValue("Q♥")).toEqual(10);
27-
expect(getCardValue("K♦")).toEqual(10);
28-
});
29-
3017
// To learn how to test whether a function throws an error as expected in Jest,
3118
// please refer to the Jest documentation:
3219
// https://jestjs.io/docs/expect#tothrowerror
33-
34-
test(`Should throw an error for invalid card rank`, () => {
35-
expect(() => getCardValue("1♠")).toThrow("Invalid card rank");
36-
expect(() => getCardValue("11♥")).toThrow("Invalid card rank");
37-
expect(() => getCardValue("Z♦")).toThrow("Invalid card rank");
38-
expect(() => getCardValue("0x02♠")).toThrow("Invalid card rank");
39-
expect(() => getCardValue("3.1416♠")).toThrow("Invalid card rank");
40-
});
41-
42-
test(`Should throw an error for invalid card suit`, () => {
43-
expect(() => getCardValue("5X")).toThrow("Invalid card suit");
44-
expect(() => getCardValue("10-")).toThrow("Invalid card suit");
45-
expect(() => getCardValue("A/")).toThrow("Invalid card suit");
46-
});

0 commit comments

Comments
 (0)