Skip to content

Commit bc5c9eb

Browse files
committed
Write tests for get-ordinal-number.test.js
1 parent eafa0bf commit bc5c9eb

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,27 @@ 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(182)).toEqual("182nd");
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 numbers ending 11, 12 or 13", () => {
35+
expect(getOrdinalNumber(11)).toEqual("11th");
36+
expect(getOrdinalNumber(12)).toEqual("12th");
37+
expect(getOrdinalNumber(13)).toEqual("13th");
38+
});
39+
40+
test("should append 'th' for numbers not ending with 1, 2 or 3", () => {
41+
expect(getOrdinalNumber(4)).toEqual("4th");
42+
expect(getOrdinalNumber(15)).toEqual("15th");
43+
expect(getOrdinalNumber(199)).toEqual("199th");
44+
});

0 commit comments

Comments
 (0)