Skip to content

Commit 4c6b2b2

Browse files
committed
Re-write the tests
1 parent 29b1e29 commit 4c6b2b2

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

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

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

1010
// Case 2: Handle Number Cards (2-10):
11-
test("should return 5 for Five of Hearts", () => {
12-
const fiveofHearts = getCardValue("5♥");
13-
expect(fiveofHearts).toEqual(5);
11+
test("should return correct value for numbered cards (2-10)", () => {
12+
expect(getCardValue("5♥")).toBe(5);
13+
expect(getCardValue("10♦")).toBe(10);
1414
});
1515
// Case 3: Handle Face Cards (J, Q, K):
16-
test("should return 10 for all face cards (J, Q, K)", () => {
17-
const faceCards = ["J♦", "Q♣", "K♥"];
18-
faceCards.forEach((card) => {
19-
const value = getCardValue(card);
20-
expect(value).toEqual(10);
16+
test("should return 'Invalid card rank' for invalid cards", () => {
17+
["1♣", "B♦", "Z♠"].forEach((card) => {
18+
expect(getCardValue(card)).toBe("Invalid card rank");
2119
});
2220
});
2321
// Case 4: Handle Ace (A):
24-
test("should return 11 for Ace of Spades", () => {
25-
const aceofSpades = getCardValue("A♠");
26-
expect(aceofSpades).toEqual(11);
22+
test("should return 11 for Ace (A)", () => {
23+
["A♠", "A♥"].forEach((card) => {
24+
expect(getCardValue(card)).toBe(11);
25+
});
2726
});
2827
// Case 5: Handle Invalid Cards:
29-
test("should return Invalid card rank for an invalid card rank", () => {
30-
const invalidCard = getCardValue("1♣");
31-
expect(invalidCard).toEqual("Invalid card rank");
32-
});
33-
test("should return Invalid card rank for another invalid card rank", () => {
34-
const anotherInvalidCard = getCardValue("B♦");
35-
expect(anotherInvalidCard).toEqual("Invalid card rank");
28+
test("should return 'Invalid card rank' for invalid cards", () => {
29+
["1♣", "B♦", "Z♠"].forEach((card) => {
30+
expect(getCardValue(card)).toBe("Invalid card rank");
31+
});
3632
});

0 commit comments

Comments
 (0)