@@ -4,10 +4,18 @@ const getOrdinalNumber = require("./get-ordinal-number");
44// continue testing and implementing getOrdinalNumber for additional cases
55// Write your tests using Jest - remember to run your tests often for continual feedback
66
7- // Case 1: Identify the ordinal number for 1
8- // When the number is 1,
9- // Then the function should return "1st"
107
11- test ( "should return '1st' for 1" , ( ) => {
8+ // To ensure thorough testing, we need broad scenarios that cover all possible cases.
9+ // Listing individual values, however, can quickly lead to an unmanageable number of test cases.
10+ // Instead of writing tests for individual numbers, consider grouping all possible input values
11+ // into meaningful categories. Then, select representative samples from each category to test.
12+ // This approach improves coverage and makes our tests easier to maintain.
13+
14+ // Case 1: Numbers ending with 1 (but not 11)
15+ // When the number ends with 1, except those ending with 11,
16+ // Then the function should return a string by appending "st" to the number.
17+ test ( "should append 'st' for numbers ending with 1, except those ending with 11" , ( ) => {
1218 expect ( getOrdinalNumber ( 1 ) ) . toEqual ( "1st" ) ;
13- } ) ;
19+ expect ( getOrdinalNumber ( 21 ) ) . toEqual ( "21st" ) ;
20+ expect ( getOrdinalNumber ( 31 ) ) . toEqual ( "131st" ) ;
21+ } ) ;
0 commit comments