Skip to content

Commit 7f0c6c8

Browse files
committed
Write test cases for invalid cards
1 parent 66f6482 commit 7f0c6c8

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@ test(`Should return 10 when given number 10 card`, () => {
4444
expect(getCardValue("10♦")).toEqual(10);
4545
});
4646

47+
// Case 3: Face Cards (J, Q, K)
48+
test(`Should return 10 when given a Kings card`, () => {
49+
expect(getCardValue("K♠")).toEqual(10);
50+
});
51+
52+
test(`Should return 10 when given a Queen card`, () => {
53+
expect(getCardValue("Q♦")).toEqual(10);
54+
});
55+
56+
test(`Should return "Invalid" when given invalid cards card`, () => {
57+
expect(() => getCardValue("")).toThrow();
58+
expect(() => getCardValue("♠")).toThrow();
59+
expect(() => getCardValue("A")).toThrow();
60+
expect(() => getCardValue("5")).toThrow();
61+
expect(() => getCardValue("1♠")).toThrow();
62+
expect(() => getCardValue("0♠")).toThrow();
63+
expect(() => getCardValue("11♠")).toThrow();
64+
expect(() => getCardValue("X♠")).toThrow();
65+
expect(() => getCardValue("5♠♥")).toThrow();
66+
});
67+
68+
// Case 4: Invalid Cards
69+
4770
// Suggestion: Group the remaining test data into these categories:
4871
// Number Cards (2-10)
4972
// Face Cards (J, Q, K)

0 commit comments

Comments
 (0)