@@ -4,24 +4,29 @@ 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// Special case: numerator is zero
7- test ( ` should return false when denominator is zero` , ( ) => {
8- expect ( isProperFraction ( - 11 , 0 ) ) . toEqual ( false ) ;
9- expect ( isProperFraction ( 0 , 0 ) ) . toEqual ( false ) ;
10- expect ( isProperFraction ( 7 , 0 ) ) . toEqual ( false ) ;
7+ test ( " should Throw new error for abs( denominator) == 0" , ( ) => {
8+ expect ( ( ) => isProperFraction ( - 11 , 0 ) ) . toThrow ( "Denominator cannot be zero" ) ;
9+ expect ( ( ) => isProperFraction ( 0 , 0 ) ) . toThrow ( "Denominator cannot be zero" ) ;
10+ expect ( ( ) => isProperFraction ( 7 , 0 ) ) . toThrow ( "Denominator cannot be zero" ) ;
1111} ) ;
1212// It should return false when the numerator > the denominator
13- test ( "should return true when numerator is 0" , ( ) => {
13+ test ( "should return false when abs( numerator) == 0" , ( ) => {
1414 expect ( isProperFraction ( 0 , - 1 ) ) . toEqual ( true ) ;
1515 expect ( isProperFraction ( 0 , 3 ) ) . toEqual ( true ) ;
1616 expect ( isProperFraction ( 0 , - 2 ) ) . toEqual ( true ) ;
1717} ) ;
18- test ( "should return true when abs(numerator) > abs(denominator)" , ( ) => {
18+ test ( "should return true when abs(numerator) < abs(denominator)" , ( ) => {
1919 expect ( isProperFraction ( - 12 , - 19 ) ) . toEqual ( true ) ;
20- expect ( isProperFraction ( 0 , 6 ) ) . toEqual ( true ) ;
20+ expect ( isProperFraction ( 3 , 6 ) ) . toEqual ( true ) ;
2121 expect ( isProperFraction ( 17 , - 71 ) ) . toEqual ( true ) ;
2222} ) ;
23- test ( "should return false when abs(numerator) < abs(denominator)" , ( ) => {
23+ test ( "should return false when abs(numerator) > abs(denominator)" , ( ) => {
2424 expect ( isProperFraction ( - 180 , - 109 ) ) . toEqual ( false ) ;
2525 expect ( isProperFraction ( 27 , 5 ) ) . toEqual ( false ) ;
2626 expect ( isProperFraction ( - 29 , 17 ) ) . toEqual ( false ) ;
2727} ) ;
28+ test ( "should return false when abs(numerator) == abs(denominator)" , ( ) => {
29+ expect ( isProperFraction ( 9 , 9 ) ) . toEqual ( false ) ;
30+ expect ( isProperFraction ( - 17 , - 17 ) ) . toEqual ( false ) ;
31+ expect ( isProperFraction ( - 15 , 15 ) ) . toEqual ( false ) ;
32+ } ) ;
0 commit comments