Skip to content

Commit 3538f28

Browse files
committed
Revert "sprint 3 implement and rewrite - i modified the implement part of get-card-value add line 37 to 40 and also done with the rewrite tests with jest tasks."
This reverts commit c822d53.
1 parent c822d53 commit 3538f28

5 files changed

Lines changed: 6 additions & 81 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ function getCardValue(card) {
3434

3535
const faceCardValues = {'A': 11, 'J': 10, 'Q': 10, 'K': 10};
3636

37-
if(faceCardValues[value] === undefined && (Number(value) < 2 || Number(value) > 10)) {
38-
throw new Error("Invalid card");
39-
}
40-
4137
if (faceCardValues[value] !== undefined) {
4238
return faceCardValues[value];
4339
}
@@ -63,8 +59,11 @@ function assertEquals(actualOutput, targetOutput) {
6359
// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
6460
// Examples:
6561
assertEquals(getCardValue("9♠"), 9);
62+
6663
assertEquals(getCardValue("A♥"),11);
6764
assertEquals(getCardValue("10♠"),10);
65+
66+
6867
assertEquals(getCardValue("2♠"), 2);
6968
assertEquals(getCardValue("K♠"), 10);
7069
assertEquals(getCardValue("q♦"), 10);

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

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

1616
// Case 2: Right angle
17-
test(`should return "Right angle" when (Angle ===90)`, () => {
18-
// Test various acute angles, including boundary cases
19-
expect(getAngleType(90)).toEqual("Right angle");
20-
21-
});
22-
2317
// Case 3: Obtuse angles
24-
test(`should return "Obtuse angle" when ( 90 < angle < 180)`, () => {
25-
// Test various acute angles, including boundary cases
26-
expect(getAngleType(91)).toEqual("Obtuse angle");
27-
expect(getAngleType(125)).toEqual("Obtuse angle");
28-
expect(getAngleType(179)).toEqual("Obtuse angle");
29-
});
30-
3118
// Case 4: Straight angle
32-
test(`should return "Straight angle" when (angle === 180)`, () => {
33-
// Test various acute angles, including boundary cases
34-
expect(getAngleType(180)).toEqual("Straight angle");
35-
});
3619
// Case 5: Reflex angles
37-
test(`should return "Reflex angle" when (180 < angle < 360)`, () => {
38-
// Test various reflex angles, including boundary cases
39-
expect(getAngleType(181)).toEqual("Reflex angle");
40-
expect(getAngleType(270)).toEqual("Reflex angle");
41-
expect(getAngleType(359)).toEqual("Reflex angle");
42-
});
4320
// Case 6: Invalid angles
44-
test(`should return "Invalid angle" when (angle < 0 || angle > 360)`, () => {
45-
// Test various invalid angles
46-
expect(getAngleType(-1)).toEqual("Invalid angle");
47-
expect(getAngleType(361)).toEqual("Invalid angle");
48-
expect(getAngleType(0)).toEqual("Invalid angle");
49-
});

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,8 @@
33
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.
6-
test(`should return True when denominator is positive and less than numerator`, () => {
7-
expect(isProperFraction(1, 2)).toEqual(true);
8-
expect(isProperFraction(-1, 2)).toEqual(true );
9-
expect(isProperFraction(20, 21)).toEqual(true );
10-
expect(isProperFraction(60, 90)).toEqual(true );
11-
});
12-
13-
test(`should return false when denominator greater than numerator`, () => {
14-
expect(isProperFraction(10, 1)).toEqual(false);
15-
expect(isProperFraction(11, 1)).toEqual(false);
16-
});
17-
18-
test(`should return false when denominator and numerators are Equal`, () => {
19-
expect(isProperFraction(1, 1)).toEqual(false);
20-
expect(isProperFraction(-1,-1)).toEqual(false);
21-
expect(isProperFraction(-1, 1)).toEqual(false);
22-
});
236

247
// Special case: numerator is zero
258
test(`should return false when denominator is zero`, () => {
269
expect(isProperFraction(1, 0)).toEqual(false);
27-
expect(isProperFraction(-1, 0)).toEqual(false);
28-
expect(isProperFraction(0, 0)).toEqual(false);
2910
});

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,8 @@ test(`Should return 11 when given an ace card`, () => {
1111

1212
// Suggestion: Group the remaining test data into these categories:
1313
// Number Cards (2-10)
14-
test(`Should return 10 when given a number card`, () => {
15-
expect(getCardValue("2♠")).toEqual(2);
16-
expect(getCardValue("3♦")).toEqual(3);
17-
expect(getCardValue("4♣")).toEqual(4);
18-
expect(getCardValue("5♠")).toEqual(5);
19-
expect(getCardValue("6♦")).toEqual(6);
20-
expect(getCardValue("7♣")).toEqual(7);
21-
expect(getCardValue("8♠")).toEqual(8);
22-
expect(getCardValue("9♦")).toEqual(9);
23-
expect(getCardValue("10♣")).toEqual(10);
24-
});
2514
// Face Cards (J, Q, K)
26-
test(`Should return 10 when given a number card`, () => {
27-
expect(getCardValue("K♠")).toEqual(10);
28-
expect(getCardValue("q♦")).toEqual(10);
29-
expect(getCardValue("J♣")).toEqual(10);
30-
});
31-
3215
// Invalid Cards
33-
test(`Should return Invalid Cards when given invalid inputs`, () => {
34-
expect(() => getCardValue("")).toThrow();
35-
expect(() => getCardValue("11")).toThrow();
36-
expect(() => getCardValue("♠10")).toThrow();
37-
expect(() => getCardValue("invalid")).toThrow();
38-
expect(() => getCardValue("1♠")).toThrow();
39-
expect(() => getCardValue("ab")).toThrow();
40-
41-
});
4216

4317
// To learn how to test whether a function throws an error as expected in Jest,
4418
// please refer to the Jest documentation:

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"keywords": [],
1010
"author": "Code Your Future",
1111
"license": "ISC",
12-
"devDependencies": {
13-
"jest": "^30.4.2"
12+
"dependencies": {
13+
"jest": "^29.7.0"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)