Skip to content

Commit 7bc1534

Browse files
authored
Editing code
1 parent 5274005 commit 7bc1534

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99

1010
function isProperFraction(numerator, denominator) {
11+
<<<<<<< HEAD
12+
if (denominator) {
13+
return true;
14+
=======
1115
if (typeof numerator !== "number" || typeof denominator !== "number") {
1216
return false; // Invalid input types
17+
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763
1318
}
1419

1520
if (denominator === 0) {

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,93 @@
11
const isProperFraction = require("../implement/2-is-proper-fraction");
22

3+
<<<<<<< HEAD
4+
// Case 1: Proper fraction
5+
// When numerator < denominator, it should return true.
6+
test("should return true for a proper fraction", () => {
7+
=======
38
// Case 1: Proper Fraction
49
// Given a numerator smaller than denominator (2/3),
510
// When the function is called,
611
// Then it should return true because it's a proper fraction.
712
test("should return true for a proper fraction (2/3)", () => {
13+
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763
814
expect(isProperFraction(2, 3)).toEqual(true);
915
});
1016

17+
<<<<<<< HEAD
18+
// Case 2: Improper fraction
19+
// When numerator > denominator, it should return false.
20+
test("should return false for an improper fraction", () => {
21+
=======
1122
// Case 2: Improper Fraction
1223
// Given a numerator greater than denominator (5/2),
1324
// When the function is called,
1425
// Then it should return false because it's an improper fraction.
1526
test("should return false for an improper fraction (5/2)", () => {
27+
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763
1628
expect(isProperFraction(5, 2)).toEqual(false);
1729
});
1830

31+
<<<<<<< HEAD
32+
// Case 3: Negative proper fraction
33+
// When numerator is negative but |numerator| < |denominator|, it should return true.
34+
test("should return true for a negative proper fraction", () => {
35+
=======
1936
// Case 3: Negative Proper Fraction
2037
// Given a negative proper fraction (-1/2),
2138
// When the function is called,
2239
// Then it should return true because the value is between -1 and 1.
2340
test("should return true for a negative proper fraction (-1/2)", () => {
41+
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763
2442
expect(isProperFraction(-1, 2)).toEqual(true);
2543
});
2644

45+
<<<<<<< HEAD
46+
// Case 4: Equal numerator and denominator
47+
// When numerator === denominator, it should return false.
48+
test("should return false for equal numerator and denominator", () => {
49+
=======
2750
// Case 4: Equal Numerator and Denominator
2851
// Given a numerator equal to denominator (3/3),
2952
// When the function is called,
3053
// Then it should return false because it's equal to 1 (not proper).
3154
test("should return false for equal numerator and denominator (3/3)", () => {
55+
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763
3256
expect(isProperFraction(3, 3)).toEqual(false);
3357
});
3458

59+
<<<<<<< HEAD
60+
// Case 5: Zero numerator
61+
// 0 divided by any non-zero denominator is a proper fraction.
62+
test("should return true for zero numerator", () => {
63+
expect(isProperFraction(0, 5)).toEqual(true);
64+
});
65+
66+
// Case 6: Negative denominator
67+
// When denominator is negative, the fraction is still valid, so check absolute values.
68+
test("should return true when denominator is negative but |numerator| < |denominator|", () => {
69+
expect(isProperFraction(2, -3)).toEqual(true);
70+
});
71+
72+
// Case 7: Denominator is zero
73+
// Division by zero is undefined, should return false.
74+
test("should return false when denominator is zero", () => {
75+
expect(isProperFraction(3, 0)).toEqual(false);
76+
});
77+
78+
// Case 8: Both numerator and denominator are negative but |numerator| < |denominator|
79+
// Negative/negative cancels out, still a proper fraction.
80+
test("should return true when both numerator and denominator are negative and |numerator| < |denominator|", () => {
81+
expect(isProperFraction(-3, -7)).toEqual(true);
82+
});
83+
84+
// Case 9: Large numbers
85+
// It should handle large numbers correctly.
86+
test("should return true for large proper fractions", () => {
87+
expect(isProperFraction(999, 1000)).toEqual(true);
88+
});
89+
90+
=======
3591
// Case 5: Negative Improper Fraction
3692
// Given a negative improper fraction (-4/3),
3793
// When the function is called,
@@ -63,3 +119,5 @@ test("should return true for zero numerator (0/5)", () => {
63119
test("should return false for zero denominator (5/0)", () => {
64120
expect(isProperFraction(5, 0)).toEqual(false);
65121
});
122+
123+
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,39 @@ test("should return 11 for Ace of Spades", () => {
88
});
99

1010
// Case 2: Handle Number Cards (2-10):
11+
test("should return 7 for 7 of Hearts", () => {
12+
const sevenOfHearts = getCardValue("7♥");
13+
expect(sevenOfHearts).toEqual(7);
14+
});
1115
// Case 3: Handle Face Cards (J, Q, K):
16+
test("should return 10 for Jack of Diamonds", () => {
17+
const jackOfDiamonds = getCardValue("J♦");
18+
expect(jackOfDiamonds).toEqual(10);
19+
});
20+
21+
//Case 4
22+
test("should return 10 for Queen of Clubs", () => {
23+
const queenOfClubs = getCardValue("Q♣");
24+
expect(queenOfClubs).toEqual(10);
25+
});
26+
27+
test("should return 10 for King of Spades", () => {
28+
const kingOfSpades = getCardValue("K♠");
29+
expect(kingOfSpades).toEqual(10);
30+
});
31+
1232
// Case 4: Handle Ace (A):
33+
test("should return 11 for Ace of Diamonds", () => {
34+
const aceOfDiamonds = getCardValue("A♦");
35+
expect(aceOfDiamonds).toEqual(11);
36+
});
1337
// Case 5: Handle Invalid Cards:
38+
test("should return null for invalid card '1X'", () => {
39+
const invalidCard1 = getCardValue("1X");
40+
expect(invalidCard1).toBe("Invalid card rank");
41+
});
42+
test("should return null for invalid card '11H'", () => {
43+
const invalidCard2 = getCardValue("11H");
44+
expect(invalidCard2).toBe("Invalid card rank");
45+
});
46+

0 commit comments

Comments
 (0)