Skip to content

Commit d04de54

Browse files
Implement test to all cards.
1 parent 0c92b19 commit d04de54

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,25 @@ test(`Should return 11 when given an ace card`, () => {
1111

1212
// Suggestion: Group the remaining test data into these categories:
1313
// Number Cards (2-10)
14+
test("Should return the correct value for number cards", () => {
15+
expect(getCardValue("2♠")).toEqual(2);
16+
expect(getCardValue("10♦")).toEqual(10);
17+
});
18+
19+
1420
// Face Cards (J, Q, K)
21+
test("Should return 10 for face cards (J, Q, K)", () => {
22+
expect(getCardValue("J♠")).toEqual(10);
23+
expect(getCardValue("Q♠")).toEqual(10);
24+
expect(getCardValue("K♠")).toEqual(10);
25+
});
26+
27+
1528
// Invalid Cards
29+
test("Should throw an error for invalid cards", () => {
30+
expect(() => getCardValue(null)).toThrow();
31+
expect(() => getCardValue(undefined)).toThrow();
32+
})
1633

1734
// To learn how to test whether a function throws an error as expected in Jest,
1835
// please refer to the Jest documentation:

0 commit comments

Comments
 (0)