Skip to content

Commit 4b897f5

Browse files
committed
write jest test cases for isProperFraction function
1 parent 4f46450 commit 4b897f5

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,35 @@
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.
5+
// Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

77
// Special case: numerator is zero
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
// Normal case:
13+
test(`should return false when denominator is zero`, () => {
14+
expect(isProperFraction(5, 10)).toEqual(true);
15+
});
16+
// Boundary Value
17+
test(`should return false when denominator is zero`, () => {
18+
expect(isProperFraction(1, 0)).toEqual(false);
19+
});
20+
// Improper Fraction
21+
test(`should return false when denominator is zero`, () => {
22+
expect(isProperFraction(1, 1)).toEqual(false);
23+
});
24+
// Negative Value
25+
test(`should return false when denominator is zero`, () => {
26+
expect(isProperFraction(-3, 8)).toEqual(false);
27+
28+
});
29+
// Very Small
30+
test(`should return false when denominator is zero`, () => {
31+
expect(isProperFraction(0.0001, 999999)).toEqual(true);
32+
});
33+
// very large
34+
test(`should return false when denominator is zero`, () => {
35+
expect(isProperFraction(999999, 0.0001)).toEqual(false);
36+
});

0 commit comments

Comments
 (0)