Skip to content

Commit 0681a40

Browse files
committed
3-get-card-value.test.js completed
1 parent ca55531 commit 0681a40

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

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

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

1212
// Suggestion: Group the remaining test data into these categories:
1313
// Number Cards (2-10)
14+
let suits = ["♠", "♥", "♣", "♦"];
15+
for (let number = 2; number <= 10; number++) {
16+
for (let suit of suits) {
17+
test(`should return card value as number`, () => {
18+
expect(getCardValue(`${number}${suit}`)).toEqual(number);
19+
});
20+
}
21+
}
1422
// Face Cards (J, Q, K)
23+
24+
let chars = ["J", "Q", "K"];
25+
26+
for (let char of chars) {
27+
for (let suit of suits) {
28+
test(`should return card value as 10`, () => {
29+
expect(getCardValue(`${char}${suit}`)).toEqual(10);
30+
});
31+
}
32+
}
1533
// Invalid Cards
1634

35+
let invalidCards = ["22♥", "11K♠", -1, 3, "11^♠"];
36+
for (let card of invalidCards) {
37+
test(`should return "Invalid card"`, () => {
38+
expect(() => {
39+
getCardValue(card);
40+
}).toThrow();
41+
});
42+
}
43+
1744
// To learn how to test whether a function throws an error as expected in Jest,
1845
// please refer to the Jest documentation:
1946
// https://jestjs.io/docs/expect#tothrowerror
20-

0 commit comments

Comments
 (0)