@@ -18,3 +18,33 @@ 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+ // Caso 2: number ending in 2 (nd) - but no 12
23+ test ( "should append 'nd' for numbers ending with 2, except 12" , ( ) => {
24+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
25+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
26+ expect ( getOrdinalNumber ( 102 ) ) . toEqual ( "102nd" ) ;
27+ } ) ;
28+
29+ // case 3: numbers ending on 3 but no 13
30+ test ( "Should append 'rd' for numbers ending with 3, except 13" , ( ) => {
31+ expect ( getOrdinalNumber ( 23 ) ) . toEqual ( "23rd" ) ;
32+ expect ( getOrdinalNumber ( 33 ) ) . toEqual ( "33rd" ) ;
33+ } ) ;
34+
35+ // case 4: numbers exception like 11, 12 and 13 append th
36+ test ( "should append 'th' for the exceptions 11, 12, and 13" , ( ) => {
37+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
38+ expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
39+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
40+ } ) ;
41+
42+ // case 5: rest of numbers
43+ test ( "should append 'th' for number ending in 4, 5, 6, 7, 8, 9 or 0" , ( ) => {
44+ expect ( getOrdinalNumber ( 4 ) ) . toEqual ( "4th" ) ;
45+ expect ( getOrdinalNumber ( 6 ) ) . toEqual ( "6th" ) ;
46+ expect ( getOrdinalNumber ( 17 ) ) . toEqual ( "17th" ) ;
47+ expect ( getOrdinalNumber ( 18 ) ) . toEqual ( "18th" ) ;
48+ expect ( getOrdinalNumber ( 29 ) ) . toEqual ( "29th" ) ;
49+ expect ( getOrdinalNumber ( 30 ) ) . toEqual ( "30th" ) ;
50+ } ) ;
0 commit comments