Skip to content

Commit 853d408

Browse files
committed
expand Case 4 to cover more invalid card inputs
1 parent f1f5709 commit 853d408

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ test("should return 10 for face cards (J, Q, K)", () => {
2323

2424
// Case 4: Invalid cards
2525
test("should throw an error for invalid card rank", () => {
26-
expect(() => getCardValue("Z♣")).toThrow("Invalid card rank");
27-
expect(() => getCardValue("0x02♠")).toThrow("Invalid card rank");
28-
expect(() => getCardValue("2.1♠")).toThrow("Invalid card rank");
29-
expect(() => getCardValue("0002♠")).toThrow("Invalid card rank");
26+
const invalidCards = [
27+
"Z♣", // invalid letter
28+
"0x02♠", // invalid rank
29+
"2.1♠", // decimal
30+
"0002♠", // leading zeros
31+
"", // empty string
32+
"♠" // suit only
33+
];
34+
35+
invalidCards.forEach(card => {
36+
expect(() => getCardValue(card)).toThrow("Invalid card rank");
37+
});
3038
});
3139

3240

0 commit comments

Comments
 (0)