@@ -18,3 +18,48 @@ 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+ //Test that numbers ending in 11 use "th".
23+ test ( "should return 'th' for the numbers ending in 11" , ( ) => {
24+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
25+ } ) ;
26+
27+ //Test that numbers ending in 2, excluding numbers ending in 12.
28+ test ( "should append 'nd' for the numbers ending in 2, except those ending in 12" , ( ) => {
29+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
30+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
31+ expect ( getOrdinalNumber ( 132 ) ) . toEqual ( "132nd" ) ;
32+ } ) ;
33+
34+ //Test that numbers ending in 3, excluding numbers ending in 13.
35+ test ( "should append 'rd' for the numbers ending in 3, except those ending in 13" , ( ) => {
36+ expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
37+ expect ( getOrdinalNumber ( 33 ) ) . toEqual ( "33rd" ) ;
38+ expect ( getOrdinalNumber ( 133 ) ) . toEqual ( "133rd" ) ;
39+ } ) ;
40+
41+ //Test that numbers ending in 13 use "th".
42+ test ( "should return 'th' for the numbers ending in 13" , ( ) => {
43+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
44+ expect ( getOrdinalNumber ( 113 ) ) . toEqual ( "113th" ) ;
45+ } ) ;
46+
47+ //Test that numbers not ending in 1, 2, or 3 use "th".
48+ test ( "should append 'th' for other numbers" , ( ) => {
49+ expect ( getOrdinalNumber ( 4 ) ) . toEqual ( "4th" ) ;
50+ expect ( getOrdinalNumber ( 7 ) ) . toEqual ( "7th" ) ;
51+ expect ( getOrdinalNumber ( 10 ) ) . toEqual ( "10th" ) ;
52+ expect ( getOrdinalNumber ( 20 ) ) . toEqual ( "20th" ) ;
53+ } ) ;
54+
55+ //Test that larger numbers ending in 12 use "th".
56+ test ( "should return 'th' for the numbers ending in 12" , ( ) => {
57+ expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
58+ expect ( getOrdinalNumber ( 112 ) ) . toEqual ( "112th" ) ;
59+ } ) ;
60+
61+ //Test that larger numbers ending in 11 use "th".
62+ test ( "should return 'th' for the numbers ending in 11" , ( ) => {
63+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
64+ expect ( getOrdinalNumber ( 111 ) ) . toEqual ( "111th" ) ;
65+ } ) ;
0 commit comments