@@ -18,3 +18,31 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
1818 expect ( getOrdinalNumber ( 21 ) ) . toEqual ( "21st" ) ;
1919 expect ( getOrdinalNumber ( 131 ) ) . toEqual ( "131st" ) ;
2020} ) ;
21+
22+ // case 2: last two digits ending with 11,12,13
23+ test ( "should append 'th' for numbers with last digits 11,12,13" , ( ) => {
24+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
25+ expect ( getOrdinalNumber ( 313 ) ) . toEqual ( "313th" )
26+ expect ( getOrdinalNumber ( 2112 ) ) . toEqual ( "2112th" )
27+ } )
28+
29+ // Case 3: Numbers ending with 2(but not 12)
30+ test ( "should append 'nd' for numbers ending with 2, except those ending with 12" , ( ) => {
31+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
32+ expect ( getOrdinalNumber ( 52 ) ) . toEqual ( "52nd" ) ;
33+ expect ( getOrdinalNumber ( 232 ) ) . toEqual ( "232nd" ) ;
34+ } ) ;
35+
36+ // Case 4: Numbers ending with 3(but not 13)
37+ test ( "should append 'rd' for numbers ending with 3, except those ending with 13" , ( ) => {
38+ expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
39+ expect ( getOrdinalNumber ( 83 ) ) . toEqual ( "83rd" ) ;
40+ expect ( getOrdinalNumber ( 463 ) ) . toEqual ( "463rd" ) ;
41+ } ) ;
42+
43+ // case 5: Numbers ending with 4-9 and 0
44+ test ( "should append 'th' for numbers with last 4-9 and 0" , ( ) => {
45+ expect ( getOrdinalNumber ( 8 ) ) . toEqual ( "8th" ) ;
46+ expect ( getOrdinalNumber ( 3130 ) ) . toEqual ( "3130th" )
47+ expect ( getOrdinalNumber ( 2119 ) ) . toEqual ( "2119th" )
48+ } )
0 commit comments