Skip to content

Commit 8bfc6d0

Browse files
committed
Make tests more detailed and add new tests
1 parent 92027a9 commit 8bfc6d0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ test(`Should return 11 when given an ace card`, () => {
1111
});
1212

1313
// Case 2
14-
test(`Should return 10 when given an jack, queen, king`, () => {
14+
test(`Should return 10 when given a jack, queen, king`, () => {
1515
expect(getCardValue("J♠")).toEqual(10);
1616
expect(getCardValue("Q♥")).toEqual(10);
1717
expect(getCardValue("K♠")).toEqual(10);
18-
expect(() => getCardValue("K🤣")).toThrow(Error);
18+
expect(() => getCardValue("K🤣")).toThrow(
19+
"Invalid last character detected, only suits(♠♥♦♣) are allowed, but got this character:"
20+
);
1921
expect(() => getCardValue("KKW🤣")).toThrow(Error);
2022
});
2123

2224
// Case 3
2325
test(`Should return number when given a number`, () => {
2426
expect(getCardValue("2♠")).toEqual(2);
2527
expect(getCardValue("10♥")).toEqual(10);
28+
expect(() => getCardValue("0♠")).toThrow(Error);
29+
expect(() => getCardValue("1♠")).toThrow(Error);
30+
expect(() => getCardValue("10Q")).toThrow(Error);
2631
expect(() => getCardValue("423🤣")).toThrow(Error);
2732
});
2833

@@ -31,6 +36,7 @@ test("Should return error on invalid input", () => {
3136
expect(() => getCardValue(undefined)).toThrow(Error);
3237
expect(() => getCardValue(12398)).toThrow(Error);
3338
expect(() => getCardValue(NaN)).toThrow(Error);
39+
expect(() => getCardValue("♠")).toThrow(Error);
3440
});
3541

3642
// Suggestion: Group the remaining test data into these categories:

0 commit comments

Comments
 (0)