Skip to content

Commit d4ace42

Browse files
committed
Rewrote tests for 2-is-proper-fraction.test.js using Jest syntax
1 parent f09ba97 commit d4ace42

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,47 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
44

55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

7-
// Special case: numerator is zero
7+
// Special case: denominator is zero
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
// Special case: numerator is zero
13+
test(`should return true when numerator is zero`, () => {
14+
expect(isProperFraction(0, 4)).toEqual(true);
15+
});
16+
17+
// Special case: numerator equals denominator
18+
test(`should return false when numerator equals denominator`, () => {
19+
expect(isProperFraction(7, 7)).toEqual(false);
20+
});
21+
22+
// Special case: numerator is smaller than denominator
23+
test(`should return true when numerator is smaller than denominator`, () => {
24+
expect(isProperFraction(1, 2)).toEqual(true);
25+
});
26+
27+
// Special case: positive proper fraction
28+
test(`should return true for positive proper fraction`, () => {
29+
expect(isProperFraction(3, 5)).toEqual(true);
30+
});
31+
32+
// Special case: numerator is larger than denominator
33+
test(`should return false when numerator is larger than denominator`, () => {
34+
expect(isProperFraction(8, 3)).toEqual(false);
35+
});
36+
37+
// Special case: negative denominator
38+
test(`should return false when denominator is negative`, () => {
39+
expect(isProperFraction(2, -6)).toEqual(false);
40+
});
41+
42+
// Special case: negative numerator
43+
test(`should return false when numerator is negative`, () => {
44+
expect(isProperFraction(-1, 4)).toEqual(false);
45+
});
46+
47+
// Special case: small positive proper fraction
48+
test(`should return true for small positive proper fraction`, () => {
49+
expect(isProperFraction(1, 100)).toEqual(true);
50+
});

0 commit comments

Comments
 (0)