|
1 | | -// Case 2: Identify the ordinal number for 2 |
2 | | -// When the number is 2, |
3 | | -// Then the function should return "2nd" |
4 | | -test("should return '2nd' for 2", () => { |
5 | | - expect(getOrdinalNumber(2)).toEqual("2nd"); |
6 | | -}); |
7 | | - |
8 | | -// Case 3: Identify the ordinal number for 3 |
9 | | -// When the number is 3, |
10 | | -// Then the function should return "3rd" |
11 | | -test("should return '3rd' for 3", () => { |
12 | | - expect(getOrdinalNumber(3)).toEqual("3rd"); |
13 | | -}); |
14 | | - |
15 | | -// Case 4: Identify ordinal numbers ending in 1 but not 11 |
16 | | -// When the number ends with 1 but is not 11, |
17 | | -// Then the function should return the correct 'st' suffix |
18 | | -test("should return '21st' for 21", () => { |
19 | | - expect(getOrdinalNumber(21)).toEqual("21st"); |
20 | | -}); |
21 | | - |
22 | | -// Case 5: Identify ordinal numbers ending in 2 but not 12 |
23 | | -// When the number ends with 2 but is not 12, |
24 | | -// Then the function should return the correct 'nd' suffix |
25 | | -test("should return '42nd' for 42", () => { |
26 | | - expect(getOrdinalNumber(42)).toEqual("42nd"); |
27 | | -}); |
| 1 | +const getOrdinalNumber = require("./get-ordinal-number"); |
| 2 | +// In this week's prep, we started implementing getOrdinalNumber |
28 | 3 |
|
29 | | -// Case 6: Identify ordinal numbers ending in 3 but not 13 |
30 | | -// When the number ends with 3 but is not 13, |
31 | | -// Then the function should return the correct 'rd' suffix |
32 | | -test("should return '53rd' for 53", () => { |
33 | | - expect(getOrdinalNumber(53)).toEqual("53rd"); |
34 | | -}); |
| 4 | +// continue testing and implementing getOrdinalNumber for additional cases |
| 5 | +// Write your tests using Jest - remember to run your tests often for continual feedback |
35 | 6 |
|
36 | | -// Case 7: Identify teen exceptions 11, 12, 13 |
37 | | -// When the number is 11, 12, or 13, |
38 | | -// Then the function should return the correct 'th' suffix |
39 | | -test("should return '11th' for 11", () => { |
40 | | - expect(getOrdinalNumber(11)).toEqual("11th"); |
41 | | -}); |
42 | | -test("should return '12th' for 12", () => { |
43 | | - expect(getOrdinalNumber(12)).toEqual("12th"); |
44 | | -}); |
45 | | -test("should return '13th' for 13", () => { |
46 | | - expect(getOrdinalNumber(13)).toEqual("13th"); |
47 | | -}); |
| 7 | +// Case 1: Identify the ordinal number for 1 |
| 8 | +// When the number is 1, |
| 9 | +// Then the function should return "1st" |
48 | 10 |
|
49 | | -// Case 8: Identify general 'th' endings |
50 | | -// When the number does not end in 1, 2, or 3 (except teens), |
51 | | -// Then the function should return the 'th' suffix |
52 | | -test("should return '20th' for 20", () => { |
53 | | - expect(getOrdinalNumber(20)).toEqual("20th"); |
54 | | -}); |
55 | | -test("should return '100th' for 100", () => { |
56 | | - expect(getOrdinalNumber(100)).toEqual("100th"); |
| 11 | +test("should return '1st' for 1", () => { |
| 12 | + expect(getOrdinalNumber(1)).toEqual("1st"); |
57 | 13 | }); |
0 commit comments