Skip to content

Commit 3dd0121

Browse files
committed
Fix ordinal number suffix handling and extend tests
1 parent f1b150e commit 3dd0121

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎practice-tdd/get-ordinal-number.test.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,23 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
1818
expect(getOrdinalNumber(21)).toEqual("21st");
1919
expect(getOrdinalNumber(131)).toEqual("131st");
2020
});
21+
22+
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
23+
expect(getOrdinalNumber(2)).toEqual("2nd");
24+
expect(getOrdinalNumber(22)).toEqual("22nd");
25+
expect(getOrdinalNumber(102)).toEqual("102nd");
26+
});
27+
28+
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
29+
expect(getOrdinalNumber(3)).toEqual("3rd");
30+
expect(getOrdinalNumber(23)).toEqual("23rd");
31+
expect(getOrdinalNumber(103)).toEqual("103rd");
32+
});
33+
34+
test("should append 'th' for all other numbers, including 11, 12 and 13", () => {
35+
expect(getOrdinalNumber(4)).toEqual("4th");
36+
expect(getOrdinalNumber(11)).toEqual("11th");
37+
expect(getOrdinalNumber(12)).toEqual("12th");
38+
expect(getOrdinalNumber(13)).toEqual("13th");
39+
expect(getOrdinalNumber(111)).toEqual("111th");
40+
});

0 commit comments

Comments
 (0)