@@ -10,29 +10,34 @@ const getOrdinalNumber = require("./get-ordinal-number");
1010// into meaningful categories. Then, select representative samples from each category to test.
1111// This approach improves coverage and makes our tests easier to maintain
1212
13- // Case 1: Numbers ending with 1 (but not 11)
13+ // Case 1: numbers ending with 1 (but not 11)
1414test ( "should append 'st' for numbers ending with 1, except those ending with 11" , ( ) => {
1515 expect ( getOrdinalNumber ( 1 ) ) . toEqual ( "1st" ) ;
1616 expect ( getOrdinalNumber ( 21 ) ) . toEqual ( "21st" ) ;
1717 expect ( getOrdinalNumber ( 131 ) ) . toEqual ( "131st" ) ;
1818} ) ;
1919
2020// Case 2: numbers ending with 2 (except 12)
21- test ( " should append 'rd' for numberss ending witth 3 except those ending with 13" , ( ) => {
21+ test ( "should append 'nd' for numbers ending with 2 except those ending with 12" , ( ) => {
22+ expect ( getOrdinalNumber ( 2 ) ) . toEqual ( "2nd" ) ;
23+ expect ( getOrdinalNumber ( 22 ) ) . toEqual ( "22nd" ) ;
24+ } ) ;
25+
26+ // Case 3: numbers ending with 3 (except 13)
27+ test ( "should append 'rd' for numbers ending with 3 except those ending with 13" , ( ) => {
2228 expect ( getOrdinalNumber ( 3 ) ) . toEqual ( "3rd" ) ;
2329 expect ( getOrdinalNumber ( 23 ) ) . toEqual ( "23rd" ) ;
2430} ) ;
2531
26- // Case 3 numbers ending with th
32+ // Case 4: numbers ending with th
2733test ( "should append 'th' for numbers ending with 4-9 or 0" , ( ) => {
2834 expect ( getOrdinalNumber ( 4 ) ) . toEqual ( "4th" ) ;
2935 expect ( getOrdinalNumber ( 10 ) ) . toEqual ( "10th" ) ;
3036} ) ;
3137
32- // Case 4 : special cases 11,12,13
38+ // Case 5 : special cases 11, 12, 13
3339test ( "should append 'th' for numbers ending with 11, 12, 13" , ( ) => {
3440 expect ( getOrdinalNumber ( 11 ) ) . toEqual ( "11th" ) ;
3541 expect ( getOrdinalNumber ( 12 ) ) . toEqual ( "12th" ) ;
3642 expect ( getOrdinalNumber ( 13 ) ) . toEqual ( "13th" ) ;
37- } ) ;
38-
43+ } ) ;
0 commit comments