Skip to content

Commit b490736

Browse files
committed
Added Jest tests for getCardValue function
1 parent 3372770 commit b490736

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ const getCardValue = require("../implement/3-get-card-value");
88
test(`Should return 11 when given an ace card`, () => {
99
expect(getCardValue("A♠")).toEqual(11);
1010
});
11+
test(`Should return 10 when given a face card`, () => {
12+
expect(getCardValue("J♦")).toEqual(10);
13+
expect(getCardValue("Q♥")).toEqual(10);
14+
expect(getCardValue("K♣")).toEqual(10);
15+
});
16+
test(`Should return the numeric value when given a number card`, () => {
17+
expect(getCardValue("2♠")).toEqual(2);
18+
expect(getCardValue("3♥")).toEqual(3);
19+
expect(getCardValue("4♦")).toEqual(4);
20+
expect(getCardValue("5♣")).toEqual(5);
21+
expect(getCardValue("6♠")).toEqual(6);
22+
expect(getCardValue("7♥")).toEqual(7);
23+
expect(getCardValue("8♦")).toEqual(8);
24+
expect(getCardValue("9♣")).toEqual(9);
25+
expect(getCardValue("10♠")).toEqual(10);
26+
});
27+
test ('Should return invalid card error when given invalid cards', () => {
28+
expect(() => getCardValue("1♠")).toThrow();
29+
expect(() => getCardValue("11♥")).toThrow();
30+
});
31+
1132

1233
// Suggestion: Group the remaining test data into these categories:
1334
// Number Cards (2-10)

0 commit comments

Comments
 (0)