|
1 | 1 | const getOrdinalNumber = require("./get-ordinal-number"); |
2 | | -// In this week's prep, we started implementing getOrdinalNumber |
3 | 2 |
|
4 | | -// continue testing and implementing getOrdinalNumber for additional cases |
5 | | -// Write your tests using Jest - remember to run your tests often for continual feedback |
6 | | - |
7 | | -// Case 1: Identify the ordinal number for 1 |
8 | | -// When the number is 1, |
9 | | -// Then the function should return "1st" |
10 | | - |
11 | | -test("should return '1st' for 1", () => { |
| 3 | +// Test for numbers ending in 1, except those ending in 11 |
| 4 | +test("append 'st' to numbers ending in 1, except those ending in 11", () => { |
12 | 5 | expect(getOrdinalNumber(1)).toEqual("1st"); |
| 6 | + expect(getOrdinalNumber(21)).toEqual("21st"); |
| 7 | + expect(getOrdinalNumber(31)).toEqual("31st"); |
13 | 8 | }); |
14 | 9 |
|
15 | | -test("should return '2nd' for 2", () => { |
| 10 | +// Test for numbers ending in 2, except those ending in 12 |
| 11 | +test("append 'nd' to numbers ending in 2, except those ending in 12", () => { |
16 | 12 | expect(getOrdinalNumber(2)).toEqual("2nd"); |
| 13 | + expect(getOrdinalNumber(22)).toEqual("22nd"); |
| 14 | + expect(getOrdinalNumber(132)).toEqual("132nd"); |
17 | 15 | }); |
18 | 16 |
|
19 | | -test("should return '3rd' for 3", () => { |
| 17 | +// Test for numbers ending in 3, except those ending in 13 |
| 18 | +test("append 'rd' to numbers ending in 3, except those ending in 13", () => { |
20 | 19 | expect(getOrdinalNumber(3)).toEqual("3rd"); |
| 20 | + expect(getOrdinalNumber(23)).toEqual("23rd"); |
| 21 | + expect(getOrdinalNumber(133)).toEqual("133rd"); |
21 | 22 | }); |
22 | 23 |
|
23 | | -test("should return '4th' for 4", () => { |
| 24 | +// Test for numbers ending in 0, 4, 5, 6, 7, 8, 9, and those ending in 11, 12, 13 |
| 25 | +test("append 'th' to numbers ending in 0, 4, 5, 6, 7, 8, 9, and those ending in 11, 12, 13", () => { |
24 | 26 | expect(getOrdinalNumber(4)).toEqual("4th"); |
25 | | -}); |
26 | | - |
27 | | -test("should return '11th' for 11", () => { |
28 | 27 | expect(getOrdinalNumber(11)).toEqual("11th"); |
29 | | -}); |
30 | | - |
31 | | -test("should return '12th' for 12", () => { |
32 | 28 | expect(getOrdinalNumber(12)).toEqual("12th"); |
33 | | -}); |
34 | | - |
35 | | -test("should return '13th' for 13", () => { |
36 | 29 | expect(getOrdinalNumber(13)).toEqual("13th"); |
37 | | -}); |
38 | | - |
39 | | -test("should return '111th' for 111", () => { |
| 30 | + expect(getOrdinalNumber(14)).toEqual("14th"); |
| 31 | + expect(getOrdinalNumber(20)).toEqual("20th"); |
| 32 | + expect(getOrdinalNumber(100)).toEqual("100th"); |
40 | 33 | expect(getOrdinalNumber(111)).toEqual("111th"); |
41 | 34 | }); |
0 commit comments