Skip to content

Commit a2c2560

Browse files
improved the code and added more test cases
1 parent 3271ad9 commit a2c2560

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,36 @@ 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 'th' for numbers ending with 11", () => {
23+
expect(getOrdinalNumber(11)).toEqual("11th");
24+
expect(getOrdinalNumber(111)).toEqual("111th");
25+
});
26+
2127
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
2228
expect(getOrdinalNumber(2)).toEqual("2nd");
2329
expect(getOrdinalNumber(22)).toEqual("22nd");
2430
expect(getOrdinalNumber(132)).toEqual("132nd");
2531
});
32+
33+
test("should append 'th' for numbers ending with 12", () => {
34+
expect(getOrdinalNumber(12)).toEqual("12th");
35+
expect(getOrdinalNumber(112)).toEqual("112th");
36+
});
37+
2638
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
2739
expect(getOrdinalNumber(3)).toEqual("3rd");
2840
expect(getOrdinalNumber(23)).toEqual("23rd");
2941
expect(getOrdinalNumber(133)).toEqual("133rd");
3042
});
31-
test("should append 'th' for numbers ending with 4-9, and those ending with 11-13", () => {
32-
expect(getOrdinalNumber(4)).toEqual("4th");
33-
expect(getOrdinalNumber(11)).toEqual("11th");
34-
expect(getOrdinalNumber(12)).toEqual("12th");
43+
44+
test("should append 'th' for numbers ending with 13", () => {
3545
expect(getOrdinalNumber(13)).toEqual("13th");
46+
expect(getOrdinalNumber(113)).toEqual("113th");
47+
});
48+
49+
test("should append 'th' for numbers ending with 4-9", () => {
50+
expect(getOrdinalNumber(4)).toEqual("4th");
3651
expect(getOrdinalNumber(14)).toEqual("14th");
3752
expect(getOrdinalNumber(24)).toEqual("24th");
38-
expect(getOrdinalNumber(112)).toEqual("112th");
39-
expect(getOrdinalNumber(113)).toEqual("113th");
4053
});

0 commit comments

Comments
 (0)