@@ -4,7 +4,62 @@ 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
7+ // Special case: denominator is zero
88test ( `should return false when denominator is zero` , ( ) => {
99 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
1010} ) ;
11+
12+ // Special case: numerator is zero
13+ test ( `should return true when numerator is zero ` , ( ) => {
14+ expect ( isProperFraction ( 0 , 2 ) ) . toEqual ( true ) ;
15+ } ) ;
16+
17+ // numerator and denominator are both zero
18+ test ( `should return false when numerator and denominator are both zero` , ( ) => {
19+ expect ( isProperFraction ( 0 , 0 ) ) . toEqual ( false ) ;
20+ } ) ;
21+
22+ // negative numerator and positive denominator
23+ test ( `should return true when numerator is negative and denominator is positive` , ( ) => {
24+ expect ( isProperFraction ( - 1 , 2 ) ) . toEqual ( true ) ;
25+ } ) ;
26+
27+ // positive numerator, negative denominator
28+ test ( ` should return false when numerator is positive and denominator is negative` , ( ) => {
29+ expect ( isProperFraction ( 1 , - 2 ) ) . toEqual ( true ) ;
30+ } )
31+
32+ //negative numerator and denominator where numerator is smaller than denominator
33+ test ( `should return true when numerator is negative and denominator is negative and numerator is smaller than denominator` , ( ) => {
34+ expect ( isProperFraction ( - 1 , - 2 ) ) . toEqual ( true ) ;
35+ } ) ;
36+
37+ //negative numerator and denominator where numerator is bigger than denominator
38+ test ( `should return false when numerator is negative and denominator is negative and numerator is bigger than denominator` , ( ) => {
39+ expect ( isProperFraction ( - 2 , - 1 ) ) . toEqual ( false ) ;
40+ } ) ;
41+
42+ //positive numerator and denominator where numerator is smaller
43+ test ( `should return true when numerator is smaller` , ( ) => {
44+ expect ( isProperFraction ( 1 , 2 ) ) . toEqual ( true ) ;
45+ } ) ;
46+
47+ // positive numerator and denominator, numerator is larger
48+ test ( `should return false when numerator is larger` , ( ) => {
49+ expect ( isProperFraction ( 4 , 2 ) ) . toEqual ( false ) ;
50+ } ) ;
51+
52+ // equal numerator and denominator
53+ test ( `should return false when numerator and denominator are equal` , ( ) => {
54+ expect ( isProperFraction ( 4 , 4 ) ) . toEqual ( false ) ;
55+ } ) ;
56+
57+ // numerator and denominator are both floating point numbers, numerator is smaller
58+ test ( `should return true when numerator and denominator are both floating point numbers and numerator is smaller` , ( ) => {
59+ expect ( isProperFraction ( 1.5 , 2.5 ) ) . toEqual ( true ) ;
60+ } ) ;
61+
62+ // numerator and denominator are both floating point numbers, numerator is larger
63+ test ( `should return false when numerator and denominator are both floating point numbers and numerator is larger` , ( ) => {
64+ expect ( isProperFraction ( 2.5 , 1.5 ) ) . toEqual ( false ) ;
65+ } ) ;
0 commit comments