Skip to content

Commit dc065a9

Browse files
Implement and test getCardValue for all valid and invalid inputs
1 parent d25645c commit dc065a9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,27 @@ const getCardValue = require("../implement/3-get-card-value");
88
test(`Should return 11 when given an ace card`, () => {
99
expect(getCardValue("A♠")).toEqual(11);
1010
});
11-
11+
test(`should return 9 when given a 9♠ card`,()=>{
12+
expect(getCardValue("9♠")).toEqual(9);
13+
});
14+
test (`should return 10 when given a face card K♦`, ()=>{
15+
expect(getCardValue("K♦")).toEqual(10);
16+
});
17+
test(`should return 10 when given a 10`, ()=>{
18+
expect(getCardValue("10♥")).toEqual(10);
19+
});
20+
test(`should throw error for invalid Ranks`, ()=>{
21+
expect(()=> getCardValue("11♠")).toThrow();
22+
});
23+
test(`should throw error for invalid Suits`, ()=>{
24+
expect(()=> getCardValue("A?")).toThrow();
25+
});
26+
test(`should throw error for missing Suits`,()=>{
27+
expect(()=> getCardValue("A")).toThrow();
28+
});
29+
test(`should throw error for non String input`, ()=>{
30+
expect(()=> getCardValue("10")).toThrow();
31+
});
1232
// Suggestion: Group the remaining test data into these categories:
1333
// Number Cards (2-10)
1434
// Face Cards (J, Q, K)

0 commit comments

Comments
 (0)