Skip to content

Commit 6152bda

Browse files
committed
test-cases written and passed for get card value.
1 parent b07437b commit 6152bda

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ test("should return 11 for Ace of Spades", () => {
88
});
99

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return correct value for number cards (2-10)", () => {
12+
expect(getCardValue("2♣")).toEqual(2);
13+
expect(getCardValue("5♦")).toEqual(5);
14+
expect(getCardValue("10♥")).toEqual(10);
15+
});
16+
1117
// Case 3: Handle Face Cards (J, Q, K):
18+
test("should return 10 for face cards (J, Q, K)", () => {
19+
expect(getCardValue("J♣")).toEqual(10);
20+
expect(getCardValue("Q♦")).toEqual(10);
21+
expect(getCardValue("K♥")).toEqual(10);
22+
});
1223
// Case 4: Handle Ace (A):
24+
test("should return 11 for Ace (A)", () => {
25+
expect(getCardValue("A♣")).toEqual(11);
26+
expect(getCardValue("A♦")).toEqual(11);
27+
expect(getCardValue("A♥")).toEqual(11);
28+
});
1329
// Case 5: Handle Invalid Cards:
30+
test("should return null for invalid cards", () => {
31+
expect(getCardValue("1♣")).toBeNull();
32+
expect(getCardValue("11♦")).toBeNull();
33+
expect(getCardValue("B♥")).toBeNull();
34+
expect(getCardValue("Z♠")).toBeNull();
35+
});
36+
37+
// We can run this test file using the command `npx jest 1-get-angle-type.test.js`
38+
// in the terminal. Making sure we are in the directory where this file is located.
39+
// If we have Jest installed globally, you can simply run `jest 1-get-angle-type.test.js`
40+
// instead. If you have added a test script to your package.json file, you can also run
41+
// `npm test 1-get-angle-type.test.js` to execute the tests.

0 commit comments

Comments
 (0)