Skip to content

Commit 8bcfee0

Browse files
committed
refactor(tests): improve structure of ordinal number tests
1 parent cb9b03e commit 8bcfee0

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed
Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
const getOrdinalNumber = require("./get-ordinal-number");
2-
// In this week's prep, we started implementing getOrdinalNumber
32

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", () => {
125
expect(getOrdinalNumber(1)).toEqual("1st");
6+
expect(getOrdinalNumber(21)).toEqual("21st");
7+
expect(getOrdinalNumber(31)).toEqual("31st");
138
});
149

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", () => {
1612
expect(getOrdinalNumber(2)).toEqual("2nd");
13+
expect(getOrdinalNumber(22)).toEqual("22nd");
14+
expect(getOrdinalNumber(132)).toEqual("132nd");
1715
});
1816

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", () => {
2019
expect(getOrdinalNumber(3)).toEqual("3rd");
20+
expect(getOrdinalNumber(23)).toEqual("23rd");
21+
expect(getOrdinalNumber(133)).toEqual("133rd");
2122
});
2223

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", () => {
2426
expect(getOrdinalNumber(4)).toEqual("4th");
25-
});
26-
27-
test("should return '11th' for 11", () => {
2827
expect(getOrdinalNumber(11)).toEqual("11th");
29-
});
30-
31-
test("should return '12th' for 12", () => {
3228
expect(getOrdinalNumber(12)).toEqual("12th");
33-
});
34-
35-
test("should return '13th' for 13", () => {
3629
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");
4033
expect(getOrdinalNumber(111)).toEqual("111th");
4134
});

0 commit comments

Comments
 (0)