@@ -4,7 +4,29 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
44
55// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66
7- // Special case: numerator is zero
7+ // Special case: denominator is zero (undefined)
88test ( `should return false when denominator is zero` , ( ) => {
99 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
1010} ) ;
11+
12+ // Special case: numerator is zero (proper fraction)
13+ test ( `should return true when numerator is zero` , ( ) => {
14+ expect ( isProperFraction ( 0 , 1 ) ) . toEqual ( true ) ;
15+ } ) ;
16+
17+ // Special case: both numerator and denominator are zeros (undefined)
18+ test ( `should return false when both numerator and denominator are zero` , ( ) => {
19+ expect ( isProperFraction ( 0 , 0 ) ) . toEqual ( false ) ;
20+ } ) ;
21+
22+ // case: the absolute value of the numerater is less than the absolute value of the denominater (proper fraction)
23+ test ( `should return true for positive proper fraction` , ( ) => {
24+ expect ( isProperFraction ( 1 , 2 ) ) . toEqual ( true ) ;
25+ } ) ;
26+
27+ // case: the absolute value of the denominater is less than the absolute value of the numerater (improper fraction)
28+ test ( `should return false for positive improper fraction` , ( ) => {
29+ expect ( isProperFraction ( 2 , 1 ) ) . toEqual ( false ) ;
30+ } ) ;
31+
32+ // no need to test the cases where the denominator or numerator or both are negative as I used their absolute value in the function.
0 commit comments