Skip to content

Commit 1200ba7

Browse files
fix: enhance tests for getOrdinalNumber function to cover additional cases and improve formatting
1 parent 096d45c commit 1200ba7

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

Sprint-3/2-practice-tdd/get-ordinal-number.test.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,37 @@ const getOrdinalNumber = require("./get-ordinal-number");
1010

1111
test("should return '1st' for 1", () => {
1212
expect(getOrdinalNumber(1)).toEqual("1st");
13+
expect(getOrdinalNumber(21)).toEqual("21st")
14+
expect(getOrdinalNumber(141)).toEqual("141st")
1315
});
1416
// Case 2: Identify the ordinal number for 2
1517
// When the number is 2,
1618
// The function should then return "2nd".
1719

18-
test("Should return `2nd` for 2", () => {
19-
expect(getOrdinalNumber(2)).toEqual("2nd");
20+
test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
21+
expect(getOrdinalNumber(2)).toEqual("2nd");
22+
expect(getOrdinalNumber(22)).toEqual("22nd");
23+
expect(getOrdinalNumber(132)).toEqual("132nd");
2024
});
2125

2226
// Case 3: Identify the ordinal number for 3
2327
// When the number is 3,
2428
// The Function should the return "3rd"
2529

2630
test("Should return `3rd` for 3", () => {
27-
expect(getOrdinalNumber(3)).toEqual("3rd");
31+
expect(getOrdinalNumber(3)).toEqual("3rd");
32+
expect(getOrdinalNumber(23)).toEqual("23rd");
33+
expect(getOrdinalNumber(133)).toEqual("133rd");
2834
});
29-
// Case 4: identify the special ordinal numbers for 11, 12, 13
35+
// Case 4: identify the special ordinal numbers for 11, 12, 13
3036
// When the number is 11, 12, 13,
3137
// The function should return "11th, 12th, 13th"
3238

33-
test ("should return `11th, 12th, 13th` for special ordinal numbers ending on these", () => {
34-
expect(getOrdinalNumber(11)).toEqual("11th");
35-
expect(getOrdinalNumber(12)).toEqual("12th");
36-
expect(getOrdinalNumber(13)).toEqual("13th");
37-
expect(getOrdinalNumber(111)).toEqual("111th");
38-
expect(getOrdinalNumber(112)).toEqual("112th");
39-
expect(getOrdinalNumber(113)).toEqual("113th");
40-
});
39+
test("should return `11th, 12th, 13th` for special ordinal numbers ending on these", () => {
40+
expect(getOrdinalNumber(11)).toEqual("11th");
41+
expect(getOrdinalNumber(12)).toEqual("12th");
42+
expect(getOrdinalNumber(13)).toEqual("13th");
43+
expect(getOrdinalNumber(111)).toEqual("111th");
44+
expect(getOrdinalNumber(112)).toEqual("112th");
45+
expect(getOrdinalNumber(113)).toEqual("113th");
46+
});

0 commit comments

Comments
 (0)