Skip to content

Commit 19009a5

Browse files
Making change to help with PR
1 parent f57a756 commit 19009a5

5 files changed

Lines changed: 21 additions & 11 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212

1313
function isProperFraction(numerator, denominator) {
1414
// TODO: Implement this function
15-
if ( numerator > 0 && denominator > 0 && denominator !==0 && numerator < denominator){
15+
if(typeof numerator === "bigint"|| typeof denominator === "bigint"){
16+
return false;
17+
}
18+
19+
if ( numerator >= 0 && denominator >= 0 && denominator !==0 && numerator < denominator){
1620
return true;
1721
} else {
1822
return false

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ function getCardValue(card) {
3939
"K",
4040
];
4141
const cardSuits = ["♠", "♥", "♦", "♣"];
42-
let rank = card.slice(0,-1);
42+
if (typeof card !== "string") {
43+
throw new Error("Invalid card");
44+
}
45+
46+
let rank = card.slice(0, -1);
4347
let suit = card.slice(-1);
4448
if (
4549
typeof card !== "string" ||
@@ -61,8 +65,6 @@ function getCardValue(card) {
6165
}
6266
}
6367

64-
65-
6668
// The line below allows us to load the getCardValue function into tests in other files.
6769
// This will be useful in the "rewrite tests with jest" step.
6870
module.exports = getCardValue;
@@ -85,6 +87,7 @@ assertEquals(getCardValue("K♣"), 10);
8587
assertEquals(getCardValue("10♠"), 10);
8688
assertEquals(getCardValue("5♠"), 5);
8789

90+
8891
// Handling invalid cards
8992
try {
9093
getCardValue("invalid");

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test(`should return "Reflex angle" when ( 180 < angle < 360)`, () => {
3434
expect(getAngleType(359)).toEqual("Reflex angle");
3535
});
3636
// Case 6: Invalid angles
37-
test(`should return "Invalid angle" when ( 0 < angle && angle > 360)`, () => {
37+
test(`should return "Invalid angle" when ( 0 < angle or angle > 360)`, () => {
3838
expect(getAngleType(-1)).toEqual("Invalid angle");
3939
expect(getAngleType(-10)).toEqual("Invalid angle");
4040
expect(getAngleType(361)).toEqual("Invalid angle");

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

77
// Special case: numerator is zero
8-
test(`should return false when denominator is zero`, () => {
8+
test(`should return true when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11-
test(`should return false when numerator is zero`, () => {
12-
expect(isProperFraction(0, 1)).toEqual(false);
11+
test(`should return true when numerator is zero`, () => {
12+
expect(isProperFraction(0, 1)).toEqual(true);
1313
});
14-
test(`should return false when numerator < denominator `, () => {
14+
test(`should return false when numerator value is negative `, () => {
1515
expect(isProperFraction(-1, 2)).toEqual(false);
1616
});
17-
test(`should return false when denominator < numerator`, () => {
17+
test(`should return false when denominator value is negative`, () => {
1818
expect(isProperFraction(1, -2)).toEqual(false);
1919
});
2020
test(`should return false when denominator is bigInt`, () => {
21-
expect(isProperFraction(1, 23443243n)).toEqual(true);
21+
expect(isProperFraction(1, 23443243n)).toEqual(false);
2222
});
2323
test(`should return false when numerator is infinity`, () => {
2424
expect(isProperFraction(23432434n, 10)).toEqual(false);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ test("Should throw error for undefined", () => {
5151
expect(() => getCardValue(undefined)).toThrow("Invalid card");
5252
});
5353

54+
test("Should throw error for the card value is number", () => {
55+
expect(() => getCardValue(5)).toThrow("Invalid card");
56+
});
5457
// To learn how to test whether a function throws an error as expected in Jest,
5558
// please refer to the Jest documentation:
5659
// https://jestjs.io/docs/expect#tothrowerror

0 commit comments

Comments
 (0)