@@ -26,10 +26,63 @@ test("should append 'th' for numbers ending with 11", () => {
2626 expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
2727 expect ( getOrdinalNumber ( 111 ) ) . toEqual ( "111th" ) ;
2828 expect ( getOrdinalNumber ( 211 ) ) . toEqual ( "211th" ) ;
29- expect ( getOrdinalNumber ( 312 ) ) . toEqual ( "311th" ) ;
29+ expect ( getOrdinalNumber ( 311 ) ) . toEqual ( "311th" ) ;
3030} ) ;
3131
32- // Case 3: Numbers ending with 2 (but not 12)
32+ // Case 3 numbers ending in 12 and 13
33+ test ( "should append 'th' for numbers ending with 12 and 13" , ( ) => {
34+ expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
35+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
36+ expect ( getOrdinalNumber ( 112 ) ) . toEqual ( "112th" ) ;
37+ expect ( getOrdinalNumber ( 113 ) ) . toEqual ( "113th" ) ;
38+ } ) ;
39+
40+ // case 4: Numbers ending with 2 (but not 12)
41+ // When the number ends with 2, except those ending with 12,
42+ // Then the function should return a string by appending "nd" to the number.
43+ test ( "should append 'nd' for numbers ending with 2, except those ending with 12" , ( ) => {
44+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
45+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
46+ expect ( getOrdinalNumber ( 32 ) ) . toEqual ( "32nd" ) ;
47+ } ) ;
48+
49+ // Case 5: Numbers ending with 3 (but not 13)
50+ // When the number ends with 3, except those ending with 13,
51+ // Then the function should return a string by appending "rd" to the number.
52+ test ( "should append 'rd' for numbers ending with 3, except those ending with 13" , ( ) => {
53+ expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
54+ expect ( getOrdinalNumber ( 23 ) ) . toEqual ( "23rd" ) ;
55+ expect ( getOrdinalNumber ( 33 ) ) . toEqual ( "33rd" ) ;
56+ } ) ;
57+
58+ // Case 6: All other numbers
59+ // When the number does not fall into any of the above categories,
60+ // Then the function should return a string by appending "th" to the number.
61+ test ( "should append 'th' for all other numbers" , ( ) => {
62+ expect ( getOrdinalNumber ( 4 ) ) . toEqual ( "4th" ) ;
63+ expect ( getOrdinalNumber ( 5 ) ) . toEqual ( "5th" ) ;
64+ expect ( getOrdinalNumber ( 6 ) ) . toEqual ( "6th" ) ;
65+ expect ( getOrdinalNumber ( 7 ) ) . toEqual ( "7th" ) ;
66+ expect ( getOrdinalNumber ( 8 ) ) . toEqual ( "8th" ) ;
67+ expect ( getOrdinalNumber ( 9 ) ) . toEqual ( "9th" ) ;
68+ expect ( getOrdinalNumber ( 10 ) ) . toEqual ( "10th" ) ;
69+ expect ( getOrdinalNumber ( 14 ) ) . toEqual ( "14th" ) ;
70+ expect ( getOrdinalNumber ( 15 ) ) . toEqual ( "15th" ) ;
71+ expect ( getOrdinalNumber ( 16 ) ) . toEqual ( "16th" ) ;
72+ expect ( getOrdinalNumber ( 17 ) ) . toEqual ( "17th" ) ;
73+ expect ( getOrdinalNumber ( 18 ) ) . toEqual ( "18th" ) ;
74+ expect ( getOrdinalNumber ( 19 ) ) . toEqual ( "19th" ) ;
75+ expect ( getOrdinalNumber ( 20 ) ) . toEqual ( "20th" ) ;
76+ expect ( getOrdinalNumber ( 24 ) ) . toEqual ( "24th" ) ;
77+ expect ( getOrdinalNumber ( 25 ) ) . toEqual ( "25th" ) ;
78+ expect ( getOrdinalNumber ( 26 ) ) . toEqual ( "26th" ) ;
79+ expect ( getOrdinalNumber ( 27 ) ) . toEqual ( "27th" ) ;
80+ expect ( getOrdinalNumber ( 28 ) ) . toEqual ( "28th" ) ;
81+ expect ( getOrdinalNumber ( 29 ) ) . toEqual ( "29th" ) ;
82+ expect ( getOrdinalNumber ( 30 ) ) . toEqual ( "30th" ) ;
83+ } ) ;
84+
85+
3386
3487
3588
0 commit comments