Skip to content

Commit ef42f92

Browse files
committed
rewrite test with jest for getcardvalue code
1 parent a223e45 commit ef42f92

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function isProperFraction(numerator, denominator) {
2020
// we could add more checks here for invalid input, but not required for this exercise
2121
}
2222

23-
// The line below allows us to load the isProperFraction function into tests in other files.
23+
// The line below allows uscd-- to load the isProperFraction function into tests in other files.
2424
// This will be useful in the "rewrite tests with jest" step.
2525
module.exports = isProperFraction;
2626

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

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

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return 7 for 7 of Hearts", () => {
12+
const sevenOfHearts = getCardValue("7♥");
13+
expect(sevenOfHearts).toEqual(7);
14+
});
1115
// Case 3: Handle Face Cards (J, Q, K):
16+
test("should return 10 for Jack of Diamonds", () => {
17+
const jackOfDiamonds = getCardValue("J♦");
18+
expect(jackOfDiamonds).toEqual(10);
19+
});
20+
21+
test("should return 10 for Queen of Clubs", () => {
22+
const queenOfClubs = getCardValue("Q♣");
23+
expect(queenOfClubs).toEqual(10);
24+
});
25+
26+
test("should return 10 for King of Spades", () => {
27+
const kingOfSpades = getCardValue("K♠");
28+
expect(kingOfSpades).toEqual(10);
29+
});
30+
1231
// Case 4: Handle Ace (A):
32+
test("should return 11 for Ace of Diamonds", () => {
33+
const aceOfDiamonds = getCardValue("A♦");
34+
expect(aceOfDiamonds).toEqual(11);
35+
});
1336
// Case 5: Handle Invalid Cards:
37+
test("should return null for invalid card '1X'", () => {
38+
const invalidCard1 = getCardValue("1X");
39+
expect(invalidCard1).toBe("Invalid card rank");
40+
});
41+
test("should return null for invalid card '11H'", () => {
42+
const invalidCard2 = getCardValue("11H");
43+
expect(invalidCard2).toBe("Invalid card rank");
44+
});
45+

0 commit comments

Comments
 (0)