@@ -4,7 +4,26 @@ 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
8- test ( `should return false when denominator is zero` , ( ) => {
9- expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
7+ // test: proper fraction
8+ // --- case 1: Proper Fractions ---
9+ test ( 'should return true for valid proper fractions, including negative numbers' , ( ) => {
10+ expect ( isProperFraction ( 5 , 9 ) ) . toBe ( true ) ;
11+ expect ( isProperFraction ( 3 , 4 ) ) . toBe ( true ) ;
12+ expect ( isProperFraction ( 2 , 8 ) ) . toBe ( true ) ;
13+ expect ( isProperFraction ( 1 , 6 ) ) . toBe ( true ) ;
14+ expect ( isProperFraction ( - 3 , - 5 ) ) . toBe ( true ) ;
1015} ) ;
16+
17+ // --- case 2: Improper Fractions ---
18+ test ( 'should return false for improper fractions where numerator >= denominator' , ( ) => {
19+ expect ( isProperFraction ( - 7 , 5 ) ) . toBe ( false ) ;
20+ expect ( isProperFraction ( 10 , 3 ) ) . toBe ( false ) ;
21+ expect ( isProperFraction ( 5 , 5 ) ) . toBe ( false ) ;
22+ } ) ;
23+
24+ // --- case 3: 0 Numerator and 0 Denominator ---
25+ test ( 'should return false when numerator or denominator is zero' , ( ) => {
26+ expect ( isProperFraction ( 3 , 0 ) ) . toBe ( false ) ;
27+ expect ( isProperFraction ( 0 , 3 ) ) . toBe ( false ) ;
28+ expect ( isProperFraction ( 0 , 0 ) ) . toBe ( false ) ;
29+ } ) ;
0 commit comments