Skip to content

Commit 22ad256

Browse files
committed
solved 3-get-card-value.test.js
1 parent 1c52048 commit 22ad256

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ test(`Should return 11 when given an ace card`, () => {
1414
// Face Cards (J, Q, K)
1515
// Invalid Cards
1616

17+
test("Should return the numeric value for cards 2 through 10", () => {
18+
expect(getCardValue("2♥")).toBe(2);
19+
expect(getCardValue("7♦")).toBe(7);
20+
expect(getCardValue("10♣")).toBe(10);
21+
});
22+
23+
test("should return 10 for all face cards (J, Q, K)", () => {
24+
expect(getCardValue("J♠")).toBe(10);
25+
expect(getCardValue("Q♥")).toBe(10);
26+
expect(getCardValue("K♦")).toBe(10);
27+
});
28+
29+
test("Should throw an error for invalid card strings", () => {
30+
expect(() => getCardValue("1♠")).toThrow("Invalid card");
31+
expect(() => getCardValue("A-Z")).toThrow("Invalid card");
32+
expect(() => getCardValue("Joker")).toThrow("Invalid card");
33+
});
34+
1735
// To learn how to test whether a function throws an error as expected in Jest,
1836
// please refer to the Jest documentation:
1937
// https://jestjs.io/docs/expect#tothrowerror

0 commit comments

Comments
 (0)