Skip to content

Commit 23d3274

Browse files
committed
Cover every standard card combination
1 parent b6b7084 commit 23d3274

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ test("Returns the value of aces and face cards", () => {
1616
assert.equal(getCardValue("K♥"), 10);
1717
});
1818

19+
const ranks = [
20+
["A", 11],
21+
["2", 2],
22+
["3", 3],
23+
["4", 4],
24+
["5", 5],
25+
["6", 6],
26+
["7", 7],
27+
["8", 8],
28+
["9", 9],
29+
["10", 10],
30+
["J", 10],
31+
["Q", 10],
32+
["K", 10],
33+
];
34+
35+
for (const [rank, expectedValue] of ranks) {
36+
for (const suit of ["♠", "♥", "♦", "♣"]) {
37+
test(`Returns ${expectedValue} for ${rank}${suit}`, () => {
38+
assert.equal(getCardValue(`${rank}${suit}`), expectedValue);
39+
});
40+
}
41+
}
42+
1943
test("Rejects invalid card strings", () => {
2044
assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error");
2145
assert.throws(() => getCardValue("1♠"));

0 commit comments

Comments
 (0)