@@ -18,3 +18,43 @@ 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: Numbers ending with 11
23+ test ( "should return 'th' for numbers ending with 11" , ( ) => {
24+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
25+ expect ( getOrdinalNumber ( 111 ) ) . toEqual ( "111th" ) ;
26+ expect ( getOrdinalNumber ( 211 ) ) . toEqual ( "211th" ) ;
27+ expect ( getOrdinalNumber ( 1011 ) ) . toEqual ( "1011th" ) ;
28+ } ) ;
29+
30+ //case:3 Numbers ending with 3 but not 13
31+ test ( "Should return 'rd' for numbers ending with 3" , ( ) => {
32+ expect ( getOrdinalNumber ( 73 ) ) . toEqual ( "73rd" ) ;
33+ expect ( getOrdinalNumber ( 93 ) ) . toEqual ( "93rd" ) ;
34+ expect ( getOrdinalNumber ( 43 ) ) . toEqual ( "43rd" ) ;
35+ expect ( getOrdinalNumber ( 2003 ) ) . toEqual ( "2003rd" ) ;
36+ } ) ;
37+
38+ //case:4 expect Numbers ending with 13 to return th
39+ test ( " should return 'th' for numbers ending with 13" , ( ) => {
40+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
41+ expect ( getOrdinalNumber ( 413 ) ) . toEqual ( "413th" ) ;
42+ expect ( getOrdinalNumber ( 613 ) ) . toEqual ( "613th" ) ;
43+ } ) ;
44+ //case 4: expect number ending with 2 to return nd
45+ test ( " should return 'nd' for numbers ending with 2" , ( ) => {
46+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
47+ expect ( getOrdinalNumber ( 42 ) ) . toEqual ( "42nd" ) ;
48+ expect ( getOrdinalNumber ( 102 ) ) . toEqual ( "102nd" ) ;
49+ } ) ;
50+
51+ // case 5: expect number not included in the above case to return th
52+ test ( "should return 'th' for numbers ending with 4, 5,6,7,8,9,0" , ( ) => {
53+ expect ( getOrdinalNumber ( 4 ) ) . toEqual ( "4th" ) ;
54+ expect ( getOrdinalNumber ( 5 ) ) . toEqual ( "5th" ) ;
55+ expect ( getOrdinalNumber ( 6 ) ) . toEqual ( "6th" ) ;
56+ expect ( getOrdinalNumber ( 7 ) ) . toEqual ( "7th" ) ;
57+ expect ( getOrdinalNumber ( 8 ) ) . toEqual ( "8th" ) ;
58+ expect ( getOrdinalNumber ( 9 ) ) . toEqual ( "9th" ) ;
59+ expect ( getOrdinalNumber ( 10 ) ) . toEqual ( "10th" ) ;
60+ } ) ;
0 commit comments