11const isProperFraction = require ( "../implement/2-is-proper-fraction" ) ;
22
3+ < << << << HEAD
4+ // Case 1: Proper fraction
5+ // When numerator < denominator, it should return true.
6+ test ( "should return true for a proper fraction" , ( ) => {
7+ === === =
38// Case 1: Proper Fraction
49// Given a numerator smaller than denominator (2/3),
510// When the function is called,
611// Then it should return true because it's a proper fraction.
712test ( "should return true for a proper fraction (2/3)" , ( ) => {
13+ >>> >>> > 52740052 fb0ad97a2c7253a04978b14a15b9e763
814 expect ( isProperFraction ( 2 , 3 ) ) . toEqual ( true ) ;
915} ) ;
1016
17+ < << << << HEAD
18+ // Case 2: Improper fraction
19+ // When numerator > denominator, it should return false.
20+ test ( "should return false for an improper fraction" , ( ) => {
21+ === === =
1122// Case 2: Improper Fraction
1223// Given a numerator greater than denominator (5/2),
1324// When the function is called,
1425// Then it should return false because it's an improper fraction.
1526test ( "should return false for an improper fraction (5/2)" , ( ) => {
27+ >>> >>> > 52740052 fb0ad97a2c7253a04978b14a15b9e763
1628 expect ( isProperFraction ( 5 , 2 ) ) . toEqual ( false ) ;
1729} ) ;
1830
31+ < << << << HEAD
32+ // Case 3: Negative proper fraction
33+ // When numerator is negative but |numerator| < |denominator|, it should return true.
34+ test ( "should return true for a negative proper fraction" , ( ) => {
35+ === === =
1936// Case 3: Negative Proper Fraction
2037// Given a negative proper fraction (-1/2),
2138// When the function is called,
2239// Then it should return true because the value is between -1 and 1.
2340test ( "should return true for a negative proper fraction (-1/2)" , ( ) => {
41+ >>> >>> > 52740052 fb0ad97a2c7253a04978b14a15b9e763
2442 expect ( isProperFraction ( - 1 , 2 ) ) . toEqual ( true ) ;
2543} ) ;
2644
45+ < << << << HEAD
46+ // Case 4: Equal numerator and denominator
47+ // When numerator === denominator, it should return false.
48+ test ( "should return false for equal numerator and denominator" , ( ) => {
49+ === === =
2750// Case 4: Equal Numerator and Denominator
2851// Given a numerator equal to denominator (3/3),
2952// When the function is called,
3053// Then it should return false because it's equal to 1 (not proper).
3154test ( "should return false for equal numerator and denominator (3/3)" , ( ) => {
55+ >>> >>> > 52740052 fb0ad97a2c7253a04978b14a15b9e763
3256 expect ( isProperFraction ( 3 , 3 ) ) . toEqual ( false ) ;
3357} ) ;
3458
59+ < << << << HEAD
60+ // Case 5: Zero numerator
61+ // 0 divided by any non-zero denominator is a proper fraction.
62+ test ( "should return true for zero numerator" , ( ) => {
63+ expect ( isProperFraction ( 0 , 5 ) ) . toEqual ( true ) ;
64+ } ) ;
65+
66+ // Case 6: Negative denominator
67+ // When denominator is negative, the fraction is still valid, so check absolute values.
68+ test ( "should return true when denominator is negative but |numerator| < |denominator|" , ( ) => {
69+ expect ( isProperFraction ( 2 , - 3 ) ) . toEqual ( true ) ;
70+ } ) ;
71+
72+ // Case 7: Denominator is zero
73+ // Division by zero is undefined, should return false.
74+ test ( "should return false when denominator is zero" , ( ) => {
75+ expect ( isProperFraction ( 3 , 0 ) ) . toEqual ( false ) ;
76+ } ) ;
77+
78+ // Case 8: Both numerator and denominator are negative but |numerator| < |denominator|
79+ // Negative/negative cancels out, still a proper fraction.
80+ test ( "should return true when both numerator and denominator are negative and |numerator| < |denominator|" , ( ) => {
81+ expect ( isProperFraction ( - 3 , - 7 ) ) . toEqual ( true ) ;
82+ } ) ;
83+
84+ // Case 9: Large numbers
85+ // It should handle large numbers correctly.
86+ test ( "should return true for large proper fractions" , ( ) => {
87+ expect ( isProperFraction ( 999 , 1000 ) ) . toEqual ( true ) ;
88+ } ) ;
89+
90+ = === ===
3591// Case 5: Negative Improper Fraction
3692// Given a negative improper fraction (-4/3),
3793// When the function is called,
@@ -63,3 +119,5 @@ test("should return true for zero numerator (0/5)", () => {
63119test ( "should return false for zero denominator (5/0)" , ( ) => {
64120 expect ( isProperFraction ( 5 , 0 ) ) . toEqual ( false ) ;
65121} ) ;
122+
123+ > >>> >>> 52740052 fb0ad97a2c7253a04978b14a15b9e763
0 commit comments