Skip to content

Commit 5f7a512

Browse files
committed
all tasks done, ready for PR
1 parent 05c5304 commit 5f7a512

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,29 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
77
// Special case: numerator is zero
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
10+
expect(isProperFraction(-1, 0)).toEqual(false);
11+
expect(isProperFraction(0, 0)).toEqual(false);
1012
});
13+
14+
test(`should return true when the absolute value of the numerator is less than the absolute value of the denominator`, () => {
15+
expect(isProperFraction(1, 2)).toEqual(true);
16+
expect(isProperFraction(-1, 2)).toEqual(true);
17+
expect(isProperFraction(1, -2)).toEqual(true);
18+
expect(isProperFraction(-1, -2)).toEqual(true);
19+
});
20+
21+
test(`should return false when the absolute value of the numerator is greater than or equal to the absolute value of the denominator`, () => {
22+
expect(isProperFraction(2, 1)).toEqual(false);
23+
expect(isProperFraction(-2, 1)).toEqual(false);
24+
expect(isProperFraction(2, -1)).toEqual(false);
25+
expect(isProperFraction(-2, -1)).toEqual(false);
26+
expect(isProperFraction(5, 0)).toEqual(false);
27+
expect(isProperFraction(-5, 0)).toEqual(false);
28+
});
29+
30+
test(`should return true when the numerator is zero and the denominator is non-zero`, () => {
31+
expect(isProperFraction(0, 5)).toEqual(true);
32+
expect(isProperFraction(0, -5)).toEqual(true);
33+
}
34+
);
35+

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ 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 the correct value for number cards`, () => {
15+
expect(getCardValue("2♠")).toEqual(2);
16+
expect(getCardValue("5♠")).toEqual(5);
17+
expect(getCardValue("10♠")).toEqual(10);
18+
});
19+
1420
// Face Cards (J, Q, K)
21+
test(`Should return 10 for face cards`, () => {
22+
expect(getCardValue("J♠")).toEqual(10);
23+
expect(getCardValue("Q♠")).toEqual(10);
24+
expect(getCardValue("K♠")).toEqual(10);
25+
});
26+
1527
// Invalid Cards
28+
test(`Should throw an error for invalid card strings`, () => {
29+
expect(() => getCardValue("invalid")).toThrow("Invalid card format");
30+
expect(() => getCardValue("11♠")).toThrow("Invalid card format");
31+
expect(() => getCardValue("A♤")).toThrow("Invalid card format");
32+
expect(() => getCardValue(123)).toThrow("Card must be a string");
33+
});
1634

17-
// To learn how to test whether a function throws an error as expected in Jest,
18-
// please refer to the Jest documentation:
1935
// https://jestjs.io/docs/expect#tothrowerror
20-
36+

0 commit comments

Comments
 (0)