Skip to content

Commit 760e0f0

Browse files
committed
fixed throwing error with exact string message
1 parent 1b1293e commit 760e0f0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getCardValue(card) {
2525
// Handling invalid cards
2626
const rank = card.slice(0, -1); //rank of the card is everything except the last character of card string
2727
const suit = card.slice(-1); // suit is the last character of the card string
28-
if (!isValidCard(rank, suit)) throw new Error("Invalid card");
28+
if (!isValidCard(rank, suit)) throw new Error("Invalid Card");
2929
if (rank === "J" || rank === "Q" || rank == "K") return 10;
3030
else if (rank == "A") return 11;
3131
else return Number(rank);

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ test(`Should return 10 when given a face card`, () => {
2727
test(`Should return Error when given an invalid card`, () => {
2828
expect(() => {
2929
getCardValue("Aas♠");
30-
}).toThrow();
30+
}).toThrow("Invalid Card");
3131
expect(() => {
3232
getCardValue("What");
33-
}).toThrow();
33+
}).toThrow("Invalid Card");
3434
expect(() => {
3535
getCardValue("Q10");
3636
}).toThrow();
3737
expect(() => {
3838
getCardValue("11");
39-
}).toThrow();
39+
}).toThrow("Invalid Card");
4040
expect(() => {
4141
getCardValue("♠11");
42-
}).toThrow();
42+
}).toThrow("Invalid Card");
4343
expect(() => {
4444
getCardValue("10*");
45-
}).toThrow();
45+
}).toThrow("Invalid Card");
4646
expect(() => {
4747
getCardValue("Q_");
48-
}).toThrow();
48+
}).toThrow("Invalid Card");
4949
expect(() => {
5050
getCardValue("A10");
51-
}).toThrow();
51+
}).toThrow("Invalid Card");
5252
});
5353

5454
// Suggestion: Group the remaining test data into these categories:

0 commit comments

Comments
 (0)