@@ -48,7 +48,7 @@ test("should append 'th' for special cases 11, 12, 13", () => {
4848 expect ( getOrdinalNumber ( 212 ) ) . toEqual ( "212th" ) ;
4949} ) ;
5050
51- // Case 5: All other numbers
51+ // Case 5: All other numbers that is not end in 1,2 or 3.
5252// When the number does not end with 1, 2, or 3,
5353// Then the function should append "th".
5454test ( "should append 'th' for all other numbers" , ( ) => {
@@ -58,16 +58,16 @@ test("should append 'th' for all other numbers", () => {
5858 expect ( getOrdinalNumber ( 204 ) ) . toEqual ( "204th" ) ;
5959} ) ;
6060
61- // Case 6: Float numbers should be rounded to nearest integer
61+ // Case 6: Float numbers should be giving a error since the function do nut accept float number input
6262// When the input is a float,
6363// Then the function should round it and return the correct ordinal.
64- test ( "should round float numbers and return correct ordinal " , ( ) => {
65- expect ( getOrdinalNumber ( 1.2 ) ) . toEqual ( "1st ") ; // rounds to 1
66- expect ( getOrdinalNumber ( 1.8 ) ) . toEqual ( "2nd ") ; // rounds to 2
67- expect ( getOrdinalNumber ( 2.5 ) ) . toEqual ( "3rd ") ; // rounds to 3
68- expect ( getOrdinalNumber ( 10.51 ) ) . toEqual ( "11th ") ; // rounds to 11
69- expect ( getOrdinalNumber ( 12.49 ) ) . toEqual ( "12th ") ; // rounds to 12
70- expect ( getOrdinalNumber ( 12.5 ) ) . toEqual ( "13th ") ; // rounds to 13
64+ test ( "should return error for invalid input " , ( ) => {
65+ expect ( ( ) => getOrdinalNumber ( 1.2 ) ) . toThrow ( "Invalid input ") ;
66+ expect ( ( ) => getOrdinalNumber ( 1.8 ) ) . toThrow ( "Invalid input ") ;
67+ expect ( ( ) => getOrdinalNumber ( 2.5 ) ) . toThrow ( "Invalid input ") ;
68+ expect ( ( ) => getOrdinalNumber ( 10.51 ) ) . toThrow ( "Invalid input ") ;
69+ expect ( ( ) => getOrdinalNumber ( 12.49 ) ) . toThrow ( "Invalid input ") ;
70+ expect ( ( ) => getOrdinalNumber ( 12.5 ) ) . toThrow ( "Invalid input ") ;
7171} ) ;
7272
7373// Case 7: Invalid inputs should throw an error
0 commit comments