Skip to content

Commit eaa3920

Browse files
committed
Add Jest tests for card values
1 parent c9cc257 commit eaa3920

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,34 @@ test(`Should return 11 when given an ace card`, () => {
99

1010
// Suggestion: Group the remaining test data into these categories:
1111
// Number Cards (2-10)
12+
test("Should return 2 when given a 2 card", () => {
13+
expect(getCardValue("2♠")).toEqual(2);
14+
});
15+
16+
test("Should return 10 when given a 10 card", () => {
17+
expect(getCardValue("10♠")).toEqual(10);
18+
});
1219
// Face Cards (J, Q, K)
20+
test("Should return 10 when given a Jack", () => {
21+
expect(getCardValue("J♠")).toEqual(10);
22+
});
23+
24+
test("Should return 10 when given a Queen", () => {
25+
expect(getCardValue("Q♠")).toEqual(10);
26+
});
27+
28+
test("Should return 10 when given a King", () => {
29+
expect(getCardValue("K♠")).toEqual(10);
30+
});
1331
// Invalid Cards
32+
test("Should throw an error for invalid text", () => {
33+
expect(() => getCardValue("invalid")).toThrow();
34+
});
35+
36+
test("Should throw an error when suit is missing", () => {
37+
expect(() => getCardValue("A")).toThrow();
38+
});
1439

1540
// To learn how to test whether a function throws an error as expected in Jest,
1641
// please refer to the Jest documentation:
1742
// https://jestjs.io/docs/expect#tothrowerror
18-

0 commit comments

Comments
 (0)