Skip to content

Commit d4d1137

Browse files
committed
Use precise mathematical notation in getOrdinalNumber test descriptions
1 parent 54db0e5 commit d4d1137

1 file changed

Lines changed: 9 additions & 21 deletions

File tree

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
11
const getOrdinalNumber = require("./get-ordinal-number");
22

3-
// Case 1: Numbers ending with 1 (but not 11)
4-
test("should append 'st' for numbers ending with 1, except those ending with 11", () => {
3+
test("should append 'st' for numbers where (num % 10 === 1) and (num % 100 !== 11)", () => {
54
expect(getOrdinalNumber(1)).toEqual("1st");
65
expect(getOrdinalNumber(21)).toEqual("21st");
76
expect(getOrdinalNumber(131)).toEqual("131st");
87
});
98

10-
// Case 2: Numbers ending with 2 (but not 12)
11-
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
9+
test("should append 'nd' for numbers where (num % 10 === 2) and (num % 100 !== 12)", () => {
1210
expect(getOrdinalNumber(2)).toEqual("2nd");
1311
expect(getOrdinalNumber(22)).toEqual("22nd");
14-
expect(getOrdinalNumber(132)).toEqual("132nd");
12+
expect(getOrdinalNumber(12)).toEqual("12th");
1513
});
1614

17-
// Case 3: Numbers ending with 3 (but not 13)
18-
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
15+
test("should append 'rd' for numbers where (num % 10 === 3) and (num % 100 !== 13)", () => {
1916
expect(getOrdinalNumber(3)).toEqual("3rd");
20-
expect(getOrdinalNumber(33)).toEqual("33rd");
21-
expect(getOrdinalNumber(133)).toEqual("133rd");
17+
expect(getOrdinalNumber(23)).toEqual("23rd");
18+
expect(getOrdinalNumber(13)).toEqual("13th");
2219
});
2320

24-
// Case 4: Numbers ending with 11, 12, or 13 are special and take "th"
25-
test("should append 'th' for numbers ending with 11, 12, or 13", () => {
21+
test("should append 'th' for numbers where (num % 10 === 0, 4-9) or (num % 100 === 11, 12, 13)", () => {
22+
expect(getOrdinalNumber(4)).toEqual("4th");
2623
expect(getOrdinalNumber(11)).toEqual("11th");
2724
expect(getOrdinalNumber(12)).toEqual("12th");
2825
expect(getOrdinalNumber(13)).toEqual("13th");
29-
expect(getOrdinalNumber(111)).toEqual("111th");
30-
expect(getOrdinalNumber(112)).toEqual("112th");
31-
expect(getOrdinalNumber(113)).toEqual("113th");
26+
expect(getOrdinalNumber(20)).toEqual("20th");
3227
});
33-
34-
// Case 5: All other numbers
35-
test("should append 'th' for all other numbers", () => {
36-
expect(getOrdinalNumber(4)).toEqual("4th");
37-
expect(getOrdinalNumber(10)).toEqual("10th");
38-
expect(getOrdinalNumber(100)).toEqual("100th");
39-
});

0 commit comments

Comments
 (0)