File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Sprint-3/1-implement-and-rewrite-tests Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 1212
1313function isProperFraction ( numerator , denominator ) {
1414 // TODO: Implement this function
15+ if ( denominator === 0 ) return false ;
16+ return Math . abs ( numerator ) < Math . abs ( denominator ) ;
1517}
1618
1719// The line below allows us to load the isProperFraction function into tests in other files.
Original file line number Diff line number Diff line change @@ -8,3 +8,18 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88test ( `should return false when denominator is zero` , ( ) => {
99 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
1010} ) ;
11+
12+ test ( `for positive` , ( ) => {
13+ expect ( isProperFraction ( 6 , 7 ) ) . toEqual ( true ) ;
14+ expect ( isProperFraction ( 2 , 4 ) ) . toEqual ( true ) ;
15+ } ) ;
16+
17+ test ( `should return false for improper fractions` , ( ) => {
18+ expect ( isProperFraction ( 8 , 6 ) ) . toEqual ( false ) ;
19+ expect ( isProperFraction ( 4 , 2 ) ) . toEqual ( false ) ;
20+ } ) ;
21+
22+ test ( `negative combinations` , ( ) => {
23+ expect ( isProperFraction ( - 5 , 9 ) ) . toEqual ( true ) ;
24+ expect ( isProperFraction ( - 2 , 0 ) ) . toEqual ( false ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments