Skip to content

Commit 77cf05b

Browse files
committed
Added in testing code for Incorrect Suit and fixed errors with lacking () => in my thrown error tests
1 parent 67f4dd7 commit 77cf05b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ test(`Should return 10 when given a J, Q, K`, () => {
2626

2727
// Invalid Cards
2828
test(`Should throw error 'expected a number followed by a suit, but got "invalid"' with invalid card`, () => {
29-
expect(getCardValue("12♥")).toThrow;
29+
expect(() => getCardValue("12♥")).toThrow;
3030
new Error('expected a number followed by a suit, but got "invalid"');
31-
expect(getCardValue("20♦")).toThrow;
31+
expect(() => getCardValue("20♦")).toThrow;
3232
new Error('expected a number followed by a suit, but got "invalid"');
3333
});
3434
// To learn how to test whether a function throws an error as expected in Jest,
3535
// please refer to the Jest documentation:
3636
// https://jestjs.io/docs/expect#tothrowerror
37+
38+
test(`Should throw error "Incorrect suit given" when given wrong symbol"`, () => {
39+
expect(() => getCardValue("2☺")).toThrow;
40+
new Error("Incorrect suit given");
41+
});

0 commit comments

Comments
 (0)