@@ -18,3 +18,32 @@ 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+
23+ // Case 2: Numbers ending with 2 (but not 12)
24+ test ( "should append 'nd' for numbers ending with 2, except those ending with 12" , ( ) => {
25+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
26+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
27+ expect ( getOrdinalNumber ( 132 ) ) . toEqual ( "132nd" ) ;
28+ } ) ;
29+ test ( "should append 'th' for numbers ending with 2 that are also ending with 12" , ( ) => {
30+ expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
31+ expect ( getOrdinalNumber ( 112 ) ) . toEqual ( "112th" ) ;
32+ } ) ;
33+
34+ // Case 3: Numbers ending with 3 (but not 13)
35+ test ( "should append 'rd' for numbers ending with 3, except those ending with 13" , ( ) => {
36+ expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
37+ expect ( getOrdinalNumber ( 23 ) ) . toEqual ( "23rd" ) ;
38+ expect ( getOrdinalNumber ( 133 ) ) . toEqual ( "133rd" ) ;
39+ } ) ;
40+ test ( "should append 'th' for numbers ending with 3 that are also ending with 13" , ( ) => {
41+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
42+ expect ( getOrdinalNumber ( 113 ) ) . toEqual ( "113th" ) ;
43+ } ) ;
44+
45+ // Case 4: All other numbers
46+ test ( "should append 'th' for all other numbers" , ( ) => {
47+ expect ( getOrdinalNumber ( 4 ) ) . toEqual ( "4th" ) ;
48+ expect ( getOrdinalNumber ( 5 ) ) . toEqual ( "5th" ) ;
49+ } ) ;
0 commit comments