@@ -4,7 +4,42 @@ 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+ // Proper fractions - should return true
8+ test ( `should return true for proper fractions (0 < numerator < denominator)` , ( ) => {
9+ expect ( isProperFraction ( 1 , 2 ) ) . toEqual ( true ) ;
10+ expect ( isProperFraction ( 3 , 4 ) ) . toEqual ( true ) ;
11+ expect ( isProperFraction ( 1 , 5 ) ) . toEqual ( true ) ;
12+ expect ( isProperFraction ( 2 , 3 ) ) . toEqual ( true ) ;
13+ expect ( isProperFraction ( 5 , 8 ) ) . toEqual ( true ) ;
14+ expect ( isProperFraction ( 1 , 100 ) ) . toEqual ( true ) ;
15+ } ) ;
16+
17+ // Improper fractions - should return false
18+ test ( `should return false for improper fractions (numerator >= denominator)` , ( ) => {
19+ expect ( isProperFraction ( 2 , 1 ) ) . toEqual ( false ) ;
20+ expect ( isProperFraction ( 5 , 3 ) ) . toEqual ( false ) ;
21+ expect ( isProperFraction ( 4 , 4 ) ) . toEqual ( false ) ;
22+ expect ( isProperFraction ( 10 , 5 ) ) . toEqual ( false ) ;
23+ expect ( isProperFraction ( 100 , 99 ) ) . toEqual ( false ) ;
24+ } ) ;
25+
26+ // Edge cases with zero - should return false
27+ test ( `should return false when numerator is zero` , ( ) => {
28+ expect ( isProperFraction ( 0 , 5 ) ) . toEqual ( false ) ;
29+ expect ( isProperFraction ( 0 , 1 ) ) . toEqual ( false ) ;
30+ expect ( isProperFraction ( 0 , 100 ) ) . toEqual ( false ) ;
31+ } ) ;
32+
33+ // Special case: denominator is zero
834test ( `should return false when denominator is zero` , ( ) => {
935 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
36+ expect ( isProperFraction ( 5 , 0 ) ) . toEqual ( false ) ;
37+ } ) ;
38+
39+ // Negative numbers - should return false
40+ test ( `should return false for negative numbers` , ( ) => {
41+ expect ( isProperFraction ( - 1 , 2 ) ) . toEqual ( false ) ;
42+ expect ( isProperFraction ( 1 , - 2 ) ) . toEqual ( false ) ;
43+ expect ( isProperFraction ( - 1 , - 2 ) ) . toEqual ( false ) ;
44+ expect ( isProperFraction ( - 5 , - 3 ) ) . toEqual ( false ) ;
1045} ) ;
0 commit comments