@@ -5,6 +5,35 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
55// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66
77// Special case: numerator is zero
8+
9+ test ( `should return true when numerator < denominator and both are integers` , ( ) => {
10+ expect ( isProperFraction ( 1 , 2 ) ) . toEqual ( true ) ;
11+ expect ( isProperFraction ( 3 , 9 ) ) . toEqual ( true ) ;
12+ expect ( isProperFraction ( 99 , 100 ) ) . toEqual ( true ) ;
13+ } ) ;
14+
15+ test ( `should return false when denominator = zero` , ( ) => {
16+ expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
17+ expect ( isProperFraction ( 5 , 0 ) ) . toEqual ( false ) ;
18+ } ) ;
19+
20+ test ( `should return false when numerator = zero` , ( ) => {
21+ expect ( isProperFraction ( 0 , 5 ) ) . toEqual ( false ) ;
22+ expect ( isProperFraction ( 0 , 7 ) ) . toEqual ( false ) ;
23+ } ) ;
24+
25+ test ( `should return false when numerator > denominator` , ( ) => {
26+ expect ( isProperFraction ( 3 , 2 ) ) . toEqual ( false ) ;
27+ expect ( isProperFraction ( 9 , 3 ) ) . toEqual ( false ) ;
28+ expect ( isProperFraction ( 36 , 7 ) ) . toEqual ( false ) ;
29+ } ) ;
30+
31+ test ( `should return false when either numerator or denominator or both are float numbers` , ( ) => {
32+ expect ( isProperFraction ( 1.5 , 2 ) ) . toEqual ( false ) ;
33+ expect ( isProperFraction ( 6 , 7.1 ) ) . toEqual ( false ) ;
34+ expect ( isProperFraction ( 3.56 , 2.4 ) ) . toEqual ( false ) ;
35+ } ) ;
36+
837test ( `should return false when denominator is zero` , ( ) => {
938 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
1039} ) ;
0 commit comments