Skip to content

Commit 4beee73

Browse files
committed
Complete Jest test suite for getCardValue
1 parent 281357c commit 4beee73

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ 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 correct value for number cards", () => {
15+
expect(getCardValue("2♠")).toEqual(2);
16+
expect(getCardValue("7♦")).toEqual(7);
17+
expect(getCardValue("10♥")).toEqual(10);
18+
});
1419
// 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+
});
1525
// Invalid Cards
16-
26+
test("Should throw an error for invalid cards", () => {
27+
expect(() => getCardValue("1♠")).toThrow();
28+
expect(() => getCardValue("11♦")).toThrow();
29+
expect(() => getCardValue("A?")).toThrow();
30+
expect(() => getCardValue("♠A")).toThrow();
31+
expect(() => getCardValue("")).toThrow();
32+
expect(() => getCardValue("10♠♠")).toThrow();
33+
});
1734
// To learn how to test whether a function throws an error as expected in Jest,
1835
// please refer to the Jest documentation:
1936
// https://jestjs.io/docs/expect#tothrowerror
20-

0 commit comments

Comments
 (0)