Skip to content

Commit 5e63f68

Browse files
authored
update the jest code
1 parent 7bc1534 commit 5e63f68

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

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

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

1010
// Case 2: Handle Number Cards (2-10):
11-
test("should return 7 for 7 of Hearts", () => {
12-
const sevenOfHearts = getCardValue("7♥");
13-
expect(sevenOfHearts).toEqual(7);
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 Jack of Diamonds", () => {
17-
const jackOfDiamonds = getCardValue("J♦");
18-
expect(jackOfDiamonds).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");
19+
});
1920
});
20-
21-
//Case 4
22-
test("should return 10 for Queen of Clubs", () => {
23-
const queenOfClubs = getCardValue("Q♣");
24-
expect(queenOfClubs).toEqual(10);
25-
});
26-
27-
test("should return 10 for King of Spades", () => {
28-
const kingOfSpades = getCardValue("K♠");
29-
expect(kingOfSpades).toEqual(10);
30-
});
31-
3221
// Case 4: Handle Ace (A):
33-
test("should return 11 for Ace of Diamonds", () => {
34-
const aceOfDiamonds = getCardValue("A♦");
35-
expect(aceOfDiamonds).toEqual(11);
22+
test("should return 11 for Ace (A)", () => {
23+
["A♠", "A♥"].forEach((card) => {
24+
expect(getCardValue(card)).toBe(11);
25+
});
3626
});
3727
// Case 5: Handle Invalid Cards:
38-
test("should return null for invalid card '1X'", () => {
39-
const invalidCard1 = getCardValue("1X");
40-
expect(invalidCard1).toBe("Invalid card rank");
41-
});
42-
test("should return null for invalid card '11H'", () => {
43-
const invalidCard2 = getCardValue("11H");
44-
expect(invalidCard2).toBe("Invalid card rank");
45-
});
46-
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+
});
32+
});

0 commit comments

Comments
 (0)