Skip to content

Commit 12bd011

Browse files
implemented tests to check for ordinal numbers
1 parent c46fdb0 commit 12bd011

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,89 @@ const getOrdinalNumber = require("./get-ordinal-number");
1111
test("should return '1st' for 1", () => {
1212
expect(getOrdinalNumber(1)).toEqual("1st");
1313
});
14+
15+
// Case 2: Identify the ordinal number for 2
16+
// When the number is 2,
17+
// Then the function should return "2nd"
18+
19+
test("should return '2nd' for 2", () => {
20+
expect(getOrdinalNumber(2)).toEqual("2nd");
21+
});
22+
23+
// Case 3: Identify the ordinal number for 3
24+
// When the number is 3,
25+
// Then the function should return "3rd"
26+
27+
test("should return '3rd' for 3", () => {
28+
expect(getOrdinalNumber(3)).toEqual("3rd");
29+
});
30+
31+
// Case 4: Identify the ordinal number for 11
32+
// When the number is 11,
33+
// Then the function should return "11th"
34+
35+
test("should return '11th' for 11", () => {
36+
expect(getOrdinalNumber(11)).toEqual("11th");
37+
});
38+
39+
// Case 5: Identify the ordinal number for 12
40+
// When the number is 12,
41+
// Then the function should return "12th"
42+
43+
test("should return '12th' for 12", () => {
44+
expect(getOrdinalNumber(12)).toEqual("12th");
45+
});
46+
47+
// Case 6: Identify the ordinal number for 13
48+
// When the number is 13,
49+
// Then the function should return "13th"
50+
51+
test("should return '13th' for 13", () => {
52+
expect(getOrdinalNumber(13)).toEqual("13th");
53+
});
54+
55+
// Case 7: Identify the ordinal number for 5
56+
// When the number is 5,
57+
// Then the function should return "5th"
58+
test("should return '5th' for 5", () => {
59+
expect(getOrdinalNumber(5)).toEqual("5th");
60+
});
61+
62+
// Case 8: Identify the ordinal number for 1035
63+
// When the number is 1035,
64+
// Then the function should return "1035th"
65+
test("should return '1035th' for 1035", () => {
66+
expect(getOrdinalNumber(1035)).toEqual("1035th");
67+
});
68+
69+
// Case 9: Identify the ordinal number for 111
70+
// When the number is 111,
71+
// Then the function should return "111th"
72+
test("should return '111th' for 111", () => {
73+
expect(getOrdinalNumber(111)).toEqual("111th");
74+
});
75+
76+
// Case 10: Identify the ordinal number for 321
77+
// When the number is 321,
78+
// Then the function should return "321st"
79+
test("should return '321st' for 321", () => {
80+
expect(getOrdinalNumber(321)).toEqual("321st");
81+
});
82+
83+
// Case 11: Identify the ordinal number for 0
84+
// When the number is 0,
85+
// Then the function should throw error
86+
test("should return error for 0", () => {
87+
expect(() => getOrdinalNumber(0)).toThrow(
88+
"Only integer numbers,bigger than 0"
89+
);
90+
});
91+
92+
// Case 12: Identify the ordinal number for -1
93+
// When the number is -1,
94+
// Then the function should throw error
95+
test("should return error for -1", () => {
96+
expect(() => getOrdinalNumber(-1)).toThrow(
97+
"Only integer numbers,bigger than 0"
98+
);
99+
});

0 commit comments

Comments
 (0)