Skip to content

Commit 06520c4

Browse files
committed
wrote jest test cases for getCardValue function
1 parent 5eb49c7 commit 06520c4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ test(`Should return 11 when given an ace card`, () => {
1111

1212
// Suggestion: Group the remaining test data into these categories:
1313
// Number Cards (2-10)
14-
test(`Should return 11 when given an ace card`, () => {
15-
expect(getCardValue("A♠")).toEqual(11);
14+
test(`Should return should return its numeric value`, () => {
15+
expect(getCardValue("9♠")).toEqual(9);
1616
});
1717
// Face Cards (J, Q, K)
18-
test(`Should return 11 when given an ace card`, () => {
19-
expect(getCardValue("A♠")).toEqual(11);
18+
test(`Should return 10`, () => {
19+
expect(getCardValue("K♠")).toEqual(10);
2020
});
2121
// Invalid Cards
22-
test(`Should return 11 when given an ace card`, () => {
23-
expect(getCardValue("A♠")).toEqual(11);
22+
test(`Should throw an error`, () => {
23+
expect(() => {
24+
getCardValue("♠9");
25+
}).toThrow();
26+
});
27+
test(`Should throw an error`, () => {
28+
expect(() => {
29+
getCardValue("♠");
30+
}).toThrow();
2431
});
2532

2633
// To learn how to test whether a function throws an error as expected in Jest,

0 commit comments

Comments
 (0)