Skip to content

Commit d25645c

Browse files
Add Jest tests for ProperFraction
1 parent 88bd4e6 commit d25645c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function isProperFraction(numerator, denominator) {
2727

2828
// The line below allows us to load the isProperFraction function into tests in other files.
2929
// This will be useful in the "rewrite tests with jest" step.
30-
//module.exports = isProperFraction;
30+
module.exports = isProperFraction;
3131

3232
// Here's our helper again
3333
function assertEquals(actualOutput, targetOutput) {
@@ -45,7 +45,7 @@ assertEquals(isProperFraction(1, 2), true);
4545
assertEquals(isProperFraction(5, 4), false);
4646
assertEquals(isProperFraction(3, 3), false);
4747
assertEquals(isProperFraction(0, 5), true);
48-
assertEquals(isProperFraction(3, 0), false);
48+
assertEquals(isProperFraction(1, 0), false);
4949
assertEquals(isProperFraction(-3, 2), true);
5050
assertEquals(isProperFraction(2, -5), false);
5151
assertEquals(isProperFraction(-2, -3), false);

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,24 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88
test(`should return false when denominator is zero`, () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
test(`Should return true when numerator is zero`, ()=>{
12+
expect(isProperFraction(0, 5)).toEqual(true);
13+
});
14+
test(`should return true when denominator is greater than numerator`, () =>{
15+
expect(isProperFraction(1, 2)).toEqual(true);
16+
});
17+
test(`should return false when numerator is greater than denominator`, ()=> {
18+
expect(isProperFraction(5, 4)).toEqual(false);
19+
});
20+
test(`should return false when numerator is equals to denominator`, ()=>{
21+
expect(isProperFraction(3, 3)).toEqual(false);
22+
});
23+
test(`should return true when denominator is greater than negative numerator`, ()=>{
24+
expect(isProperFraction(-3, 2)).toEqual(true);
25+
});
26+
test(`should return false when numerator is greater than denominator`, ()=> {
27+
expect(isProperFraction(2, -5)).toEqual(false);
28+
});
29+
test(`should return false when negative numerator is greater than negative denominator`, ()=> {
30+
expect(isProperFraction(-2, -3)).toEqual(false);
31+
});

0 commit comments

Comments
 (0)