Skip to content

Commit f718131

Browse files
authored
Rewrite tests for isProperFraction using Jest
Added Jest test cases for proper fraction validation.
1 parent d9a7a5b commit f718131

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

77
// Special case: numerator is zero
8-
test(`should return false when denominator is zero`, () => {
8+
test('should return false when denominator is zero', () => {
99
expect(isProperFraction(1, 0)).toEqual(false);
1010
});
11+
12+
//[Chun Yan Wong]
13+
14+
test('returns true when numerator absolute value is less than denominator absolute value', () => {
15+
expect(isProperFraction(1, 2)).toEqual(true);
16+
expect(isProperFraction(-1, 2)).toEqual(true);
17+
expect(isProperFraction(3, -5)).toEqual(true);
18+
});
19+
20+
test('returns false when numerator absolute value is equal to denominator absolute value', () => {
21+
expect(isProperFraction(2, 2)).toEqual(false);
22+
expect(isProperFraction(-3, 3)).toEqual(false);
23+
});
24+
25+
test('returns false when numerator absolute value is greater than denominator absolute value', () => {
26+
expect(isProperFraction(5, 2)).toEqual(false);
27+
expect(isProperFraction(-7, 3)).toEqual(false);
28+
});

0 commit comments

Comments
 (0)