Skip to content

Commit 3449903

Browse files
committed
Mirror exhaustive card coverage in Jest
1 parent 23d3274 commit 3449903

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ test.each([
1212
expect(getCardValue(card)).toEqual(expectedValue);
1313
});
1414

15+
const ranks = [
16+
["A", 11],
17+
["2", 2],
18+
["3", 3],
19+
["4", 4],
20+
["5", 5],
21+
["6", 6],
22+
["7", 7],
23+
["8", 8],
24+
["9", 9],
25+
["10", 10],
26+
["J", 10],
27+
["Q", 10],
28+
["K", 10],
29+
];
30+
const suits = ["♠", "♥", "♦", "♣"];
31+
32+
test.each(
33+
ranks.flatMap(([rank, expectedValue]) =>
34+
suits.map((suit) => [`${rank}${suit}`, expectedValue]),
35+
),
36+
)("returns the expected value for %s", (card, expectedValue) => {
37+
expect(getCardValue(card)).toEqual(expectedValue);
38+
});
39+
1540
test.each(["invalid", "1♠", "11♠", "A", "A X", "A🃏"])(
1641
"rejects invalid card %s",
1742
(card) => {

0 commit comments

Comments
 (0)