Skip to content

Commit 3f52c42

Browse files
committed
Throw an error for "Invalid card rank." and update the test to expect an error to be thrown
1 parent 0bf4436 commit 3f52c42

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
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
@@ -17,7 +17,7 @@ function getCardValue(card) {
1717
} else if (rank >= 2 && rank <= 10) {
1818
return Number(rank);
1919
} else {
20-
return "Invalid card rank.";
20+
return new Error("Invalid card rank.");
2121
}
2222
}
2323

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ test("should return 11 for an Ace", () => {
3333

3434
// Case 5: Handle Invalid Cards:
3535
test("should return `Invalid card rank.` for an invalid card", () => {
36-
const invalidRank = getCardValue("@");
37-
expect(invalidRank).toEqual("Invalid card rank.");
36+
expect(() => getCardValue("@").toThrow("Invalid card rank."));
3837
});

0 commit comments

Comments
 (0)