33const 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.
6+ describe ( "isProperFraction" , ( ) => {
7+ // Denominator zero case
8+ test ( "should return false when denominator is zero" , ( ) => {
9+ expect ( isProperFraction ( 1 , 0 ) ) . toBe ( false ) ;
10+ } ) ;
611
7- // Special case: numerator is zero
8- test ( `should return false when denominator is zero` , ( ) => {
9- expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
10- } ) ;
12+ // Denominator negative case
13+ test ( "should return false when denominator is negative" , ( ) => {
14+ expect ( isProperFraction ( 1 , - 5 ) ) . toBe ( false ) ;
15+ expect ( isProperFraction ( - 3 , - 4 ) ) . toBe ( false ) ;
16+ } ) ;
17+
18+ // Proper positive fraction (numerator < denominator)
19+ test ( "should return true for positive proper fractions" , ( ) => {
20+ expect ( isProperFraction ( 1 , 2 ) ) . toBe ( true ) ;
21+ expect ( isProperFraction ( 3 , 4 ) ) . toBe ( true ) ;
22+ } ) ;
23+
24+ // Improper positive fraction (numerator >= denominator)
25+ test ( "should return false for improper positive fractions" , ( ) => {
26+ expect ( isProperFraction ( 4 , 3 ) ) . toBe ( false ) ;
27+ expect ( isProperFraction ( 5 , 5 ) ) . toBe ( false ) ;
28+ } ) ;
29+
30+ // Negative numerators (proper fraction)
31+ test ( "should return true for negative proper fractions" , ( ) => {
32+ expect ( isProperFraction ( - 1 , 3 ) ) . toBe ( true ) ;
33+ } ) ;
34+
35+ // Negative numerators that make fraction improper
36+ test ( "should return false for negative improper fractions" , ( ) => {
37+ expect ( isProperFraction ( - 5 , 5 ) ) . toBe ( false ) ;
38+ } ) ;
39+
40+ // Mixed sign case (denominator positive, numerator positive/negative)
41+ test ( "should handle mixed signs correctly" , ( ) => {
42+ expect ( isProperFraction ( 2 , 3 ) ) . toBe ( true ) ;
43+ expect ( isProperFraction ( - 2 , 3 ) ) . toBe ( true ) ;
44+ expect ( isProperFraction ( 4 , 3 ) ) . toBe ( false ) ;
45+ expect ( isProperFraction ( - 4 , 3 ) ) . toBe ( false ) ;
46+ } ) ;
47+ } ) ;
0 commit comments