Skip to content

Commit f59e42d

Browse files
completed sprint 3 task 2 exercise 1 and 2
made some changes to the implement proper fraction
1 parent 9bf34d7 commit f59e42d

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

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

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

1313
function isProperFraction(numerator, denominator) {
1414
switch (true) {
15-
case Math.abs(numerator / denominator) < 1:
15+
case Math.abs(numerator / denominator) < 1 &&
16+
Math.abs(numerator / denominator) > 0:
1617
return true;
1718
default:
1819
return false;

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ 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 FALSE when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
test("should return FALSE when numerator is zero", () => {
13+
expect(isProperFraction(0, 5)).toEqual(false);
14+
});
15+
16+
test("should return TRUE when numerator is negative and smaller than denominator", () => {
17+
expect(isProperFraction(-1, 7)).toEqual(true);
18+
});
19+
20+
test("should return TRUE when denominator is negative AND bigger than numerator", () => {
21+
expect(isProperFraction(1, -7)).toEqual(true);
22+
});
23+
24+
test("should return FALSE when numerator > denominator ", () => {
25+
expect(isProperFraction(9, 7)).toEqual(false);
26+
});
27+
28+
test("should return TRUE when numerator < denominator ", () => {
29+
expect(isProperFraction(4, 7)).toEqual(true);
30+
});
31+
32+
test("should return TRUE when numerator AND denominator are negative values and the denominator is bigger than numerator", () => {
33+
expect(isProperFraction(-4, -7)).toEqual(true);
34+
});

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ test(`Should return 11 when given an ace card`, () => {
1717
// To learn how to test whether a function throws an error as expected in Jest,
1818
// please refer to the Jest documentation:
1919
// https://jestjs.io/docs/expect#tothrowerror
20-

0 commit comments

Comments
 (0)