Skip to content

Commit 8006ddf

Browse files
committed
fix isProperFraction test suite
1 parent 4648537 commit 8006ddf

2 files changed

Lines changed: 17 additions & 37 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ function assertEquals(actualOutput, targetOutput) {
2727
);
2828
}
2929

30-
// TODO: Write tests to cover all cases.
31-
// What combinations of numerators and denominators should you test?
32-
3330
// Example: 1/2 is a proper fraction
3431
assertEquals(isProperFraction(1, 2), true);
3532
assertEquals(isProperFraction(2, 1), false);

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

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,31 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const isProperFraction = require("../implement/2-is-proper-fraction");
44

5-
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
6-
7-
// Special case: numerator is zero
8-
test(`should return false when denominator is zero`, () => {
9-
expect(isProperFraction(1, 0)).toEqual(false);
10-
});
11-
// This statement loads the isProperFraction function you wrote in the implement directory.
12-
// We will use the same function, but write tests for it using Jest in this file.
13-
const isProperFraction = require("../implement/2-is-proper-fraction");
14-
15-
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
16-
17-
// Special case: numerator is zero
185
test(`should return false when denominator is zero`, () => {
19-
expect(isProperFraction(1, 0)).toEqual(false);
20-
expect(isProperFraction(0, 0)).toEqual(false);
216
expect(isProperFraction(-1, 0)).toEqual(false);
7+
expect(isProperFraction(0, 0)).toEqual(false);
8+
expect(isProperFraction(1, 0)).toEqual(false);
229
});
2310

24-
test(`should return true when numerator and denominator both positive and numerator < denominator`, () => {
25-
expect(isProperFraction(1, 2)).toEqual(true);
26-
expect(isProperFraction(4, 5)).toEqual(true);
27-
expect(isProperFraction(2, 3)).toEqual(true);
28-
});
29-
30-
test(`should return true when numerator and denominator both negative and numerator < denominator`, () => {
31-
expect(isProperFraction(-3, -2)).toEqual(true);
32-
});
33-
34-
test(`should return true when numerator is negative and numerator < denominator`, () => {
35-
expect(isProperFraction(-3, 2)).toEqual(true);
36-
});
37-
38-
test(`should return false when numerator > denominator`, () => {
39-
expect(isProperFraction(2, 1)).toEqual(false);
11+
test(`should return true when numerator is zero`, () => {
12+
expect(isProperFraction(0, -1)).toEqual(true);
13+
expect(isProperFraction(0, 100)).toEqual(true);
4014
});
4115

42-
test(`should return false when numerator > denominator, negative nums`, () => {
43-
expect(isProperFraction(-1, -2)).toEqual(false);
16+
test(`should return false when |numerator| > |denominator|`, () => {
17+
expect(isProperFraction(-3, -2)).toEqual(false);
18+
expect(isProperFraction(3, 2)).toEqual(false);
19+
expect(isProperFraction(-3, 2)).toEqual(false);
4420
});
4521

46-
test(`should return false when numerator == denominator`, () => {
22+
test(`should return false when |numerator| == |denominator|`, () => {
4723
expect(isProperFraction(-2, -2)).toEqual(false);
4824
expect(isProperFraction(2, 2)).toEqual(false);
25+
expect(isProperFraction(-2, 2)).toEqual(false);
26+
});
27+
28+
test(`should return true when |numerator| < |denominator|`, () => {
29+
expect(isProperFraction(2, 3)).toEqual(true);
30+
expect(isProperFraction(-3, -4)).toEqual(true);
31+
expect(isProperFraction(-2, 3)).toEqual(true);
4932
});

0 commit comments

Comments
 (0)