@@ -15,6 +15,37 @@ import { getOrdinalNumber } from "./get-ordinal-number.js";
1515// Then the function should return a string by appending "st" to the number.
1616test ( "should append 'st' for numbers ending with 1, except those ending with 11" , ( ) => {
1717 expect ( getOrdinalNumber ( 1 ) ) . toEqual ( "1st" ) ;
18+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
19+ expect ( getOrdinalNumber ( 111 ) ) . toEqual ( "111th" ) ;
1820 expect ( getOrdinalNumber ( 21 ) ) . toEqual ( "21st" ) ;
1921 expect ( getOrdinalNumber ( 131 ) ) . toEqual ( "131st" ) ;
2022} ) ;
23+ // Case 2: Numbers ending with 2 (but not 12)
24+ // When the number ends with 2, except those ending with 12,
25+ // Then the function should return a string by appending "nd" to the number.
26+ test ( "should append 'nd' for numbers ending with 2, except those ending with 12" , ( ) => {
27+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
28+ expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
29+ expect ( getOrdinalNumber ( 112 ) ) . toEqual ( "112th" ) ;
30+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
31+ expect ( getOrdinalNumber ( 132 ) ) . toEqual ( "132nd" ) ;
32+ } ) ;
33+ // Case 3: Numbers ending with 3 (but not 13)
34+ // When the number ends with 3, except those ending with 13,
35+ // Then the function should return a string by appending "rd" to the number.
36+ test ( "should append 'rd' for numbers ending with 3, except those ending with 13" , ( ) => {
37+ expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
38+ expect ( getOrdinalNumber ( 33 ) ) . toEqual ( "33rd" ) ;
39+ expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
40+ expect ( getOrdinalNumber ( 113 ) ) . toEqual ( "113th" ) ;
41+ expect ( getOrdinalNumber ( 133 ) ) . toEqual ( "133rd" ) ;
42+ } ) ;
43+ // Case 4: Numbers ending within the range of 4-9 (also ending with 0)
44+ // When the number ends within the range of 4-9 or ends with 0.
45+ // Then the function should return a string by appending "th" to the number.
46+ test ( "should append 'th' for numbers ending within 4-9, or ends with 0" , ( ) => {
47+ expect ( getOrdinalNumber ( 5 ) ) . toEqual ( "5th" ) ;
48+ expect ( getOrdinalNumber ( 37 ) ) . toEqual ( "37th" ) ;
49+ expect ( getOrdinalNumber ( 139 ) ) . toEqual ( "139th" ) ;
50+ expect ( getOrdinalNumber ( 100 ) ) . toEqual ( "100th" ) ;
51+ } ) ;
0 commit comments