Skip to content

Commit fd090c5

Browse files
committed
Write jest tests for 1-implement-and-rewrite-test/rewrite-test-with-jest/3-get-card-value.test.js
1 parent bae2cd3 commit fd090c5

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ test(`Should return number when given an a face card (>= 2 && < 10)`, () => {
2121
expect(getCardValue("9♠")).toEqual(9);
2222
});
2323

24-
test(`Should return an error for an invalid card`, () => {
25-
expect(getCardValue("2")).toThrowError();
26-
expect(getCardValue("Q")).toThrowError();
27-
expect(getCardValue("5")).toThrowError();
24+
// Invalid cards
25+
test(`Should return "Invalid card suit" when suit is invalid`, () => {
26+
expect(() => getCardValue("A")).toThrowError();
27+
});
28+
29+
test(`Should return "Invalid card rank" when rank is invalid`, () => {
30+
expect(() => getCardValue("1♠")).toThrowError();
31+
});
32+
33+
test(`Should return "Invalid card" when rank is an empty card`, () => {
34+
expect(() => getCardValue("")).toThrowError();
2835
});
2936

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"author": "Code Your Future",
1111
"license": "ISC",
1212
"devDependencies": {
13-
"jest": "^30.4.2"
13+
"jest": "^29.7.0"
1414
}
1515
}

0 commit comments

Comments
 (0)