Skip to content

Commit 39e1bfc

Browse files
made descriptions more concise and added tests for negative numbers
1 parent 23b24d4 commit 39e1bfc

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
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-
// Special case: numerator is zero
6-
test(`should return true when the numerator is zero`, () => {
5+
// Special case: numerator equals zero
6+
test(`returns true if numerator equals zero`, () => {
77
expect(isProperFraction(0, 1)).toEqual(true);
8+
expect(isProperFraction(0, -2)).toEqual(true);
89
});
910

10-
test(`should return true when the denominator is bigger then the numerator` => {
11+
test(`returns true when abs(denominator) > abs(numerator)`, () => {
1112
expect(isProperFraction(1, 2)).toEqual(true);
13+
expect(isProperFraction(-1, 2)).toEqual(true);
14+
expect(isProperFraction(-1, -2)).toEqual(true);
15+
expect(isProperFraction(0, 1)).toEqual(true);
1216
});
1317

14-
test(`should return false when the denominator is equal to the numerator`, () => {
18+
test(`returns false when denominator equals numerator`, () => {
1519
expect(isProperFraction(2, 2)).toEqual(false);
20+
expect(isProperFraction(-2, -2)).toEqual(false);
1621
});
1722

18-
test(`should return false when the denominator is smaller than the numerator`, () => {
23+
test(`returns false when abs(denominator) < abs(numerator)`, () => {
1924
expect(isProperFraction(2, 1)).toEqual(false);
25+
expect(isProperFraction(-2, 1)).toEqual(false);
26+
expect(isProperFraction(2, -1)).toEqual(false);
27+
expect(isProperFraction(-2, -1)).toEqual(false);
2028
});
2129

22-
test(`should return false when the denominator and the numerator are both zero`, () => {
30+
test(`returns false when 0/0`, () => {
2331
expect(isProperFraction(0, 0)).toEqual(false);
2432
});
2533

26-
test(`should return false when the denominator is zero`, () => {
34+
test(`returns false when denominator equals 0`, () => {
2735
expect(isProperFraction(1, 0)).toEqual(false);
36+
expect(isProperFraction(-1, 0)).toEqual(false);
2837
});

0 commit comments

Comments
 (0)