Skip to content

Commit f39d27a

Browse files
committed
Rewrite getCardValue tests using Jest
1 parent f08aec2 commit f39d27a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ test(`Should return 11 when given an ace card`, () => {
99
expect(getCardValue("A♠")).toEqual(11);
1010
});
1111

12+
// Number Cards (2-10)
13+
test(`Should return the correct number for number cards`, () => {
14+
expect(getCardValue("2♠")).toEqual(2);
15+
expect(getCardValue("9♥")).toEqual(9);
16+
expect(getCardValue("10♦")).toEqual(10);
17+
});
18+
19+
// Face Cards (J, Q, K)
20+
test(`Should return 10 for face cards`, () => {
21+
expect(getCardValue("J♣")).toEqual(10);
22+
expect(getCardValue("Q♦")).toEqual(10);
23+
expect(getCardValue("K♠")).toEqual(10);
24+
});
25+
26+
// Invalid Cards
27+
test(`Should throw an error for invalid card strings`, () => {
28+
const invalidCards = ["", "A", "11♠", "1♠", "B♠", "10X", "♠A", "invalid"];
29+
30+
for (const badCard of invalidCards) {
31+
expect(() => getCardValue(badCard)).toThrowError();
32+
}
33+
});
34+
35+
1236
// Suggestion: Group the remaining test data into these categories:
1337
// Number Cards (2-10)
1438
// Face Cards (J, Q, K)

0 commit comments

Comments
 (0)