Skip to content

Commit 1a4ec4e

Browse files
committed
Add more tests to cover 10,11,12,13
1 parent 73f8459 commit 1a4ec4e

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test("should append 'rd' for numbers ending with 3, except those ending with 13"
2929
expect(getOrdinalNumber(23)).toEqual("23rd");
3030
expect(getOrdinalNumber(133)).toEqual("133rd");
3131
});
32-
test("should append 'th' for numbers ending with 0, 4-9, 11, 12, 13", () => {
32+
test("should append 'th' for numbers ending with 0, 4-9, 10, 11, 12, 13", () => {
3333
// 0
3434
expect(getOrdinalNumber(0)).toEqual("0th");
3535
expect(getOrdinalNumber(10)).toEqual("10th");
@@ -63,9 +63,21 @@ test("should append 'th' for numbers ending with 0, 4-9, 11, 12, 13", () => {
6363
expect(getOrdinalNumber(9)).toEqual("9th");
6464
expect(getOrdinalNumber(29)).toEqual("29th");
6565
expect(getOrdinalNumber(139)).toEqual("139th");
66+
67+
// 10
68+
expect(getOrdinalNumber(10)).toEqual("10th");
69+
expect(getOrdinalNumber(100)).toEqual("100th");
70+
71+
// 11, 12, 13
72+
expect(getOrdinalNumber(11)).toEqual("11th");
73+
expect(getOrdinalNumber(12)).toEqual("12th");
74+
expect(getOrdinalNumber(13)).toEqual("13th");
6675
});
6776

6877
// edge cases
6978
test("should throw an error when given a wrong input type", () => {
70-
expect(getOrdinalNumber("string")).toThrow(Error);
79+
expect(() => getOrdinalNumber("testing string")).toThrow("Invalid type for ");
80+
expect(() => getOrdinalNumber("")).toThrow();
81+
expect(() => getOrdinalNumber(null)).toThrow();
82+
expect(() => getOrdinalNumber(undefined)).toThrow();
7183
});

0 commit comments

Comments
 (0)