Skip to content

Commit f89c2e1

Browse files
refactor: reorganize tests for getCardValue function for clarity and consistency
1 parent 7a00c6a commit f89c2e1

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,29 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const getCardValue = require("../implement/3-get-card-value");
44

5-
test("should return 11 for Ace of Spades", () => {
6-
const aceOfSpades = getCardValue("A♠");
7-
expect(aceOfSpades).toEqual(11);
8-
});
5+
96

107
// Case 2: Handle Number Cards (2-10):
8+
test("should return 5 for five of spades ",()=>{
9+
const fiveOfSpades = getCardValue("5♠");
10+
expect(fiveOfSpades).toEqual(5)
11+
})
1112
// Case 3: Handle Face Cards (J, Q, K):
13+
test("should return 10 for king of spades",()=>{
14+
const kingOfSpades = getCardValue("K♠");
15+
expect(kingOfSpades).toEqual(10)
16+
})
1217
// Case 4: Handle Ace (A):
18+
test("should return 11 for Ace of Spades", () => {
19+
const aceOfSpades = getCardValue("A♠");
20+
expect(aceOfSpades).toEqual(11);
21+
});
1322
// Case 5: Handle Invalid Cards:
23+
test("should through error for 1 of spades",()=>{
24+
expect(()=> getCardValue("1♠")).toThrow('Invalid card rank: 1')
25+
})
26+
27+
28+
test("should throw error for five*",()=>{
29+
expect(() => getCardValue("5*")).toThrow("Invalid card face: *");
30+
})

0 commit comments

Comments
 (0)