Skip to content

Commit eb68334

Browse files
committed
Write multiple test cases for proper and improper fraction
1 parent c0bc7b7 commit eb68334

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

‎implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test("Decimal improper fraction", () => {
4242
assert.equal(isProperFraction(1.2, 1.1), false);
4343
});
4444

45-
test("Large numerator improper fraction", () => {
45+
test("Large numerator improper fraction", () => {
4646
assert.equal(isProperFraction(5, 3), false);
4747
});
4848

‎implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,56 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
66
test(`should return false when denominator is zero`, () => {
77
expect(isProperFraction(1, 0)).toEqual(false);
88
});
9+
10+
test(`should return true for basic proper fraction`, () => {
11+
expect(isProperFraction(1, 2)).toEqual(true);
12+
});
13+
14+
test(`should return true for decimal proper fraction`, () => {
15+
expect(isProperFraction(0.5, 1.5)).toEqual(true);
16+
});
17+
18+
test(`should return true for 0 numerator proper fraction`, () => {
19+
expect(isProperFraction(0, 5)).toEqual(true);
20+
});
21+
22+
test(`should return true for negative numerator proper fraction`, () => {
23+
expect(isProperFraction(-9, 1)).toEqual(true);
24+
});
25+
26+
test(`should return true for negative proper fraction`, () => {
27+
expect(isProperFraction(-7, -3)).toEqual(true);
28+
});
29+
30+
test(`should return true for very small denominator proper fraction`, () => {
31+
expect(isProperFraction(1, 1000000)).toEqual(true);
32+
});
33+
34+
// Improper fractions
35+
test(`should return false for very small denominator proper fraction`, () => {
36+
expect(isProperFraction(1.2, 1.1)).toEqual(false);
37+
});
38+
39+
test(`should return false for large numerator improper fraction`, () => {
40+
expect(isProperFraction(5, 3)).toEqual(false);
41+
});
42+
43+
test(`should return false for both equal numbers improper fraction`, () => {
44+
expect(isProperFraction(4, 4)).toEqual(false);
45+
});
46+
47+
test(`should return false for 0 denominator improper fraction`, () => {
48+
expect(isProperFraction(7, 0)).toEqual(false);
49+
});
50+
51+
test(`should return false for both 0 improper fraction`, () => {
52+
expect(isProperFraction(0, 0)).toEqual(false);
53+
});
54+
55+
test(`should return false for both negative improper fraction`, () => {
56+
expect(isProperFraction(-4, -4)).toEqual(false);
57+
});
58+
59+
test(`should return false for negative denominator improper fraction`, () => {
60+
expect(isProperFraction(2, -9)).toEqual(false);
61+
});

0 commit comments

Comments
 (0)