@@ -69,3 +69,68 @@ test("should return false when 3.5 > 2.5", () => {
6969test ( "should return false for non-numeric inputs" , ( ) => {
7070 expect ( isProperFraction ( "a" , 2 ) ) . toEqual ( false ) ;
7171} ) ;
72+
73+ // Stretch 10: numerator is a string that can be converted to a number
74+ test ( "should return true when '2' < 3" , ( ) => {
75+ expect ( isProperFraction ( "2" , 3 ) ) . toEqual ( true ) ;
76+ } ) ;
77+
78+ // Stretch 11: denominator is a string that can be converted to a number
79+ test ( "should return false when 5 > '2'" , ( ) => {
80+ expect ( isProperFraction ( 5 , "2" ) ) . toEqual ( false ) ;
81+ } ) ;
82+
83+ // Stretch 12: both numerator and denominator are strings that can be converted to numbers
84+ test ( "should return true when '2' < '3'" , ( ) => {
85+ expect ( isProperFraction ( "2" , "3" ) ) . toEqual ( true ) ;
86+ } ) ;
87+
88+ // Stretch 13: numerator is null
89+ test ( "should return false when numerator is null" , ( ) => {
90+ expect ( isProperFraction ( null , 3 ) ) . toEqual ( false ) ;
91+ } ) ;
92+
93+ // Stretch 14: denominator is null
94+ test ( "should return false when denominator is null" , ( ) => {
95+ expect ( isProperFraction ( 3 , null ) ) . toEqual ( false ) ;
96+ } ) ;
97+
98+ // Stretch 15: both numerator and denominator are null
99+ test ( "should return false when both numerator and denominator are null" , ( ) => {
100+ expect ( isProperFraction ( null , null ) ) . toEqual ( false ) ;
101+ } ) ;
102+
103+ // Stretch 16: numerator is undefined
104+ test ( "should return false when numerator is undefined" , ( ) => {
105+ expect ( isProperFraction ( undefined , 3 ) ) . toEqual ( false ) ;
106+ } ) ;
107+
108+ // Stretch 17: denominator is undefined
109+ test ( "should return false when denominator is undefined" , ( ) => {
110+ expect ( isProperFraction ( 3 , undefined ) ) . toEqual ( false ) ;
111+ } ) ;
112+
113+ // Stretch 18: both numerator and denominator are undefined
114+ test ( "should return false when both numerator and denominator are undefined" , ( ) => {
115+ expect ( isProperFraction ( undefined , undefined ) ) . toEqual ( false ) ;
116+ } ) ;
117+
118+ // Stretch 19: numerator is an array
119+ test ( "should return false when numerator is an array" , ( ) => {
120+ expect ( isProperFraction ( [ 2 ] , 3 ) ) . toEqual ( false ) ;
121+ } ) ;
122+
123+ // Stretch 20: denominator is an array
124+ test ( "should return false when denominator is an array" , ( ) => {
125+ expect ( isProperFraction ( 2 , [ 3 ] ) ) . toEqual ( false ) ;
126+ } ) ;
127+
128+ // Stretch 21: numerator is an object
129+ test ( "should return false when numerator is an object" , ( ) => {
130+ expect ( isProperFraction ( { num : 2 } , 3 ) ) . toEqual ( false ) ;
131+ } ) ;
132+
133+ // Stretch 22: denominator is an object
134+ test ( "should return false when denominator is an object" , ( ) => {
135+ expect ( isProperFraction ( 2 , { den : 3 } ) ) . toEqual ( false ) ;
136+ } ) ;
0 commit comments