@@ -13,8 +13,40 @@ const getOrdinalNumber = require("./get-ordinal-number");
1313// Case 1: Numbers ending with 1 (but not 11)
1414// When the number ends with 1, except those ending with 11,
1515// Then the function should return a string by appending "st" to the number.
16+
1617test ( "should append 'st' for numbers ending with 1, except those ending with 11" , ( ) => {
1718 expect ( getOrdinalNumber ( 1 ) ) . toEqual ( "1st" ) ;
1819 expect ( getOrdinalNumber ( 21 ) ) . toEqual ( "21st" ) ;
1920 expect ( getOrdinalNumber ( 131 ) ) . toEqual ( "131st" ) ;
2021} ) ;
22+
23+ // Case 2: Numbers ending with 2
24+ // When the number ends with 2,
25+ // Then the function should return a string by appending "nd" to the number.
26+
27+ test ( "should append 'nd' for numbers ending with 2" , ( ) => {
28+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
29+ expect ( getOrdinalNumber ( 32 ) ) . toEqual ( "32nd" ) ;
30+ expect ( getOrdinalNumber ( 252 ) ) . toEqual ( "252nd" ) ;
31+ } ) ;
32+
33+ // Case 3: Numbers ending with 3
34+ // When the number ends with 3,
35+ // Then the function should return a string by appending "rd" to the number.
36+
37+ test ( "should append 'rd' for numbers ending with 3" , ( ) => {
38+ expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
39+ expect ( getOrdinalNumber ( 33 ) ) . toEqual ( "33rd" ) ;
40+ expect ( getOrdinalNumber ( 133 ) ) . toEqual ( "133rd" ) ;
41+ } ) ;
42+
43+ // Case 4: The remaining numbers
44+ // When the number ends with 1, except those ending with 11
45+ // For all other numbers
46+ // Then the function should return a string by appending "th" to the number.
47+
48+ test ( "should append 'th' for remaining numbers" , ( ) => {
49+ expect ( getOrdinalNumber ( 20 ) ) . toEqual ( "20th" ) ;
50+ expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
51+ expect ( getOrdinalNumber ( 99 ) ) . toEqual ( "99th" ) ;
52+ } ) ;
0 commit comments