Skip to content

Commit 8f484a4

Browse files
committed
added string length requirement to card value test
1 parent 5f7a512 commit 8f484a4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
// execute the code to ensure all tests pass.
2323

2424
function getCardValue(card) {
25-
// TODO: Implement this function
25+
2626
if (typeof card !== "string") {
2727
throw new Error("Card must be a string");
2828
}
2929

30+
if (card.length < 2) {
31+
throw new Error("Card must have at least two characteristics");
32+
}
33+
3034
const rank = card.slice(0, -1);
3135
const suit = card.slice(-1);
3236

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ test(`Should throw an error for invalid card strings`, () => {
3030
expect(() => getCardValue("11♠")).toThrow("Invalid card format");
3131
expect(() => getCardValue("A♤")).toThrow("Invalid card format");
3232
expect(() => getCardValue(123)).toThrow("Card must be a string");
33+
expect(() => getCardValue(1)).toThrow("Card must have at least two characteristics");
34+
expect(() => getCardValue("")).toThrow("Card must have at least two characteristics");
3335
});
3436

3537
// https://jestjs.io/docs/expect#tothrowerror

0 commit comments

Comments
 (0)