@@ -2,7 +2,38 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
22
33// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
44
5+ // Positive numbers
6+ test ( "should return true when positive numerator is less than positive denominator" , ( ) => {
7+ expect ( isProperFraction ( 1 , 2 ) ) . toEqual ( true ) ;
8+ expect ( isProperFraction ( 3 , 4 ) ) . toEqual ( true ) ;
9+ } ) ;
10+
11+ test ( "should return false when positive numerator is equal to or greater than positive denominator" , ( ) => {
12+ expect ( isProperFraction ( 3 , 3 ) ) . toEqual ( false ) ;
13+ expect ( isProperFraction ( 5 , 2 ) ) . toEqual ( false ) ;
14+ } ) ;
15+
516// Special case: numerator is zero
6- test ( `should return false when denominator is zero` , ( ) => {
17+
18+ test ( "should return false when denominator is zero" , ( ) => {
719 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
20+ expect ( isProperFraction ( 0 , 0 ) ) . toEqual ( false ) ;
21+ } ) ;
22+
23+ test ( "should return true when numerator is zero and denominator is non-zero" , ( ) => {
24+ expect ( isProperFraction ( 0 , 5 ) ) . toEqual ( true ) ;
25+ expect ( isProperFraction ( 0 , - 5 ) ) . toEqual ( true ) ;
26+ } ) ;
27+
28+ // Negative numbers
29+ test ( "should return true when absolute value of numerator is less than denominator" , ( ) => {
30+ expect ( isProperFraction ( - 1 , 2 ) ) . toEqual ( true ) ;
31+ expect ( isProperFraction ( 1 , - 2 ) ) . toEqual ( true ) ;
32+ expect ( isProperFraction ( - 1 , - 2 ) ) . toEqual ( true ) ;
33+ } ) ;
34+
35+ test ( "should return false when absolute value of numerator is equal to or greater than denominator" , ( ) => {
36+ expect ( isProperFraction ( - 5 , 2 ) ) . toEqual ( false ) ;
37+ expect ( isProperFraction ( 5 , - 2 ) ) . toEqual ( false ) ;
38+ expect ( isProperFraction ( - 3 , - 3 ) ) . toEqual ( false ) ;
839} ) ;
0 commit comments