Skip to content

Commit 9a3c314

Browse files
committed
added tests for negative numerator/denominator cases
1 parent 608f1db commit 9a3c314

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,42 @@ test(`should return false when both numerator and denominator are zero`, () => {
1919
expect(isProperFraction(0, 0)).toEqual(false);
2020
});
2121

22-
// case: the absolute value of the numerater is less than the absolute value of the denominater (proper fraction)
22+
// case: both values are positive and the value of the numerater is less than the value of the denominater (proper fraction)
2323
test(`should return true for positive proper fraction`, () => {
2424
expect(isProperFraction(1, 2)).toEqual(true);
2525
});
2626

27-
// case: the absolute value of the denominater is less than the absolute value of the numerater (improper fraction)
27+
// case: both values are positive and the value of the denominater is less than the value of the numerater (improper fraction)
2828
test(`should return false for positive improper fraction`, () => {
2929
expect(isProperFraction(2, 1)).toEqual(false);
3030
});
3131

32-
// no need to test the cases where the denominator or numerator or both are negative as I used their absolute value in the function.
32+
// case: the value of the numerater is negative and its absolute value is less than the value of the denominater (roper fraction)
33+
test(`should return false for proper fraction`, () => {
34+
expect(isProperFraction(-1, 2)).toEqual(true);
35+
});
36+
37+
// case: the value of the numerater is negative and its absolute value is greater than the value of the denominater (improper fraction)
38+
test(`should return false for improper fraction`, () => {
39+
expect(isProperFraction(-2, 1)).toEqual(false);
40+
});
41+
42+
// case: the value of the denominator is negative and its absolute value is greater than the value of the numerator (proper fraction)
43+
test(`should return true for proper fraction`, () => {
44+
expect(isProperFraction(1, -2)).toEqual(true);
45+
});
46+
47+
// case: the value of the denominator is negative and its absolute value is less than the value of the numerator (improper fraction)
48+
test(`should return false for improper fraction`, () => {
49+
expect(isProperFraction(2, -1)).toEqual(false);
50+
});
51+
52+
// case: both values of the numerator and denominator are negative and the absolute value of the numerator is less than the absolute value of the denominator (proper fraction)
53+
test(`should return true for proper fraction`, () => {
54+
expect(isProperFraction(-1, -2)).toEqual(true);
55+
});
56+
57+
// case: both values of the numerator and denominator are negative and the absolute value of the numerator is greater than the absolute value of the denominator (improper fraction)
58+
test(`should return false for improper fraction`, () => {
59+
expect(isProperFraction(-2, -1)).toEqual(false);
60+
});

0 commit comments

Comments
 (0)