Skip to content

Commit 3e05835

Browse files
committed
wrote test cases for 2-is-proper-fraction and 3-get-card-value in sprint 3
1 parent 6335caa commit 3e05835

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
test(`should return true when numerator is zero and denominator is positive`, () => {
13+
expect(isProperFraction(0, 1)).toEqual(true);
14+
});
15+
16+
test(`should return false when numerator is zero and denominator is negative`, () => {
17+
expect(isProperFraction(0, -1)).toEqual(false);
18+
});

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,23 @@ 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 numeric value for number cards`, () => {
15+
expect(getCardValue("2♠")).toEqual(2);
16+
expect(getCardValue("10♠")).toEqual(10);
17+
});
1418
// Face Cards (J, Q, K)
19+
test(`Should return 10 for face cards`, () => {
20+
expect(getCardValue("J♠")).toEqual(10);
21+
expect(getCardValue("Q♠")).toEqual(10);
22+
expect(getCardValue("K♠")).toEqual(10);
23+
});
1524
// Invalid Cards
25+
test(`Should throw an error for invalid cards`, () => {
26+
expect(() => getCardValue("invalid")).toThrow();
27+
expect(() => getCardValue("A")).toThrow(); // Missing suit
28+
expect(() => getCardValue("11♠")).toThrow(); // Invalid rank
29+
expect(() => getCardValue("9X")).toThrow(); // Invalid suit
30+
});
1631

1732
// To learn how to test whether a function throws an error as expected in Jest,
1833
// please refer to the Jest documentation:

0 commit comments

Comments
 (0)