Skip to content

Commit f0b6faa

Browse files
committed
added jest test cases
1 parent 241ef30 commit f0b6faa

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,39 @@ test(`Should return 11 when given an ace card`, () => {
99
expect(getCardValue("A♠")).toEqual(11);
1010
});
1111

12+
test(`Should return 10 when given a Joker card`, () => {
13+
expect(getCardValue("J♥")).toEqual(10);
14+
});
15+
16+
test(`Should return 2 when given the 2 card`, () => {
17+
expect(getCardValue("2♠")).toEqual(2);
18+
});
19+
20+
test(`Should return 10 when given a King card`, () => {
21+
expect(getCardValue("K♠")).toEqual(10);
22+
});
23+
24+
test(`Should return 5 when given the 5 card`, () => {
25+
expect(getCardValue("5♠")).toEqual(5);
26+
});
27+
28+
test(`Should return 8 when gine the 8 card`, () => {
29+
expect(getCardValue("8♠")).toEqual(8);
30+
});
31+
32+
test(`Should return 10 when given the Queen card`, () => {
33+
expect(getCardValue("Q♠")).toEqual(10);
34+
});
1235
// Suggestion: Group the remaining test data into these categories:
1336
// Number Cards (2-10)
1437
// Face Cards (J, Q, K)
1538
// Invalid Cards
1639

1740
// To learn how to test whether a function throws an error as expected in Jest,
1841
// please refer to the Jest documentation:
19-
// https://jestjs.io/docs/expect#tothrowerror
20-
42+
// https://jestjs.io/docs/exåpect#tothrowerror
43+
test(`Should not return any card should throw an error message`, () => {
44+
expect(() => {
45+
getCardValue("QQ♥");
46+
}).toThrow();
47+
});

0 commit comments

Comments
 (0)