Skip to content

Commit 9bc3e9d

Browse files
committed
test: add Jest tests for getCardValue including error cases
1 parent 0e4389e commit 9bc3e9d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

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

1010
// Case 2: Handle Number Cards (2-10):
11+
test("Should return numeric value(8) for Number Cards (2-10)", () => {
12+
const aceofSpades = getCardValue("8♠");
13+
expect(aceofSpades).toEqual(8);
14+
});
1115
// Case 3: Handle Face Cards (J, Q, K):
16+
test("should return the value 10, a card with a rank of ('10', 'J', 'Q', or 'K')", () => {
17+
const aceofSpades = getCardValue("K");
18+
expect(aceofSpades).toEqual(10);
19+
});
1220
// Case 4: Handle Ace (A):
21+
test("should return the value 11,for a card with a rank of 'A' ", () => {
22+
const aceofSpades = getCardValue("A");
23+
expect(aceofSpades).toEqual(11);
24+
});
1325
// Case 5: Handle Invalid Cards:
26+
test("should throw an error,with an invalid rank 'OL'", () => {
27+
const aceofSpades = getCardValue("OL");
28+
expect(aceofSpades).toBe("Invalid card rank");
29+
});

0 commit comments

Comments
 (0)