Skip to content

Commit 4483f93

Browse files
committed
Add Jest tests for getCardValue including ace, number, face, and invalid cards
1 parent f0b9120 commit 4483f93

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,20 @@ test(`Should return 11 when given an ace card`, () => {
1313
// Number Cards (2-10)
1414
// Face Cards (J, Q, K)
1515
// Invalid Cards
16+
test("should return the value of number cards", () => {
17+
expect(getCardValue("2♣")).toEqual(2);
18+
expect(getCardValue("5♠")).toEqual(5);
19+
expect(getCardValue("10♦")).toEqual(10);
20+
});
21+
test("should return 10 for face cards", () => {
22+
expect(getCardValue("J♣")).toEqual(10);
23+
expect(getCardValue("Q♥")).toEqual(10);
24+
expect(getCardValue("K♠")).toEqual(10);
25+
});
26+
test("should throw an error for invalid card", () => {
27+
expect(() => getCardValue("1♣")).toThrow("invalid card rank.");
28+
});
1629

1730
// To learn how to test whether a function throws an error as expected in Jest,
1831
// please refer to the Jest documentation:
1932
// https://jestjs.io/docs/expect#tothrowerror
20-

0 commit comments

Comments
 (0)