Skip to content

Commit 44f3ca1

Browse files
committed
Grouping the tests
1 parent bea3492 commit 44f3ca1

File tree

1 file changed

+13
-76
lines changed

1 file changed

+13
-76
lines changed

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

Lines changed: 13 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,27 @@ const getOrdinalNumber = require("./get-ordinal-number");
44
// continue testing and implementing getOrdinalNumber for additional cases
55
// Write your tests using Jest - remember to run your tests often for continual feedback
66

7-
// Case 1: Identify the ordinal number for 1
8-
// When the number is 1,
9-
// Then the function should return "1st"
10-
11-
test("should return '1st' for 1", () => {
7+
test("append 'st' to numbers ending in 1,except those ending in 11", () => {
128
expect(getOrdinalNumber(1)).toEqual("1st");
13-
});
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 4
32-
// When the number is 4,
33-
// Then the function should return "4th"
34-
35-
test("should return '4th' for 4", () => {
36-
expect(getOrdinalNumber(4)).toEqual("4th");
37-
});
38-
39-
// Case 5: Identify the ordinal number for 11
40-
// When the number is 11,
41-
// Then the function should return "11th"
42-
43-
test("should return '11th' for 11", () => {
44-
expect(getOrdinalNumber(11)).toEqual("11th");
45-
});
46-
47-
// Case 6: Identify the ordinal number for 12
48-
// When the number is 12,
49-
// Then the function should return "12th"
50-
51-
test("should return '12th' for 12", () => {
52-
expect(getOrdinalNumber(12)).toEqual("12th");
53-
});
54-
55-
// Case 7: Identify the ordinal number for 13
56-
// When the number is 13,
57-
// Then the function should return "13th"
58-
59-
test("should return '13th' for 13", () => {
60-
expect(getOrdinalNumber(13)).toEqual("13th");
61-
});
62-
63-
// Case 8: Identify the ordinal number for 21
64-
// When the number is 21,
65-
// Then the function should return "21st"
66-
67-
test("should return '21st' for 21", () => {
689
expect(getOrdinalNumber(21)).toEqual("21st");
10+
expect(getOrdinalNumber(101)).toEqual("101st");
6911
});
7012

71-
// Case 9: Identify the ordinal number for 22
72-
// When the number is 22,
73-
// Then the function should return "22nd"
74-
75-
test("should return '22nd' for 22", () => {
13+
test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
14+
expect(getOrdinalNumber(2)).toEqual("2nd");
7615
expect(getOrdinalNumber(22)).toEqual("22nd");
16+
expect(getOrdinalNumber(132)).toEqual("132nd");
7717
});
7818

79-
// Case 10: Identify the ordinal number for 23
80-
// When the number is 23,
81-
// Then the function should return "23rd"
82-
83-
test("should return '23rd' for 23", () => {
19+
test("append 'rd' to numbers ending in 3, except those ending in 13", () => {
20+
expect(getOrdinalNumber(3)).toEqual("3rd");
8421
expect(getOrdinalNumber(23)).toEqual("23rd");
22+
expect(getOrdinalNumber(133)).toEqual("133rd");
8523
});
8624

87-
// Case 11: Identify the ordinal number for 101
88-
// When the number is 101,
89-
// Then the function should return "101st"
90-
91-
test("should return '101st' for 101", () => {
92-
expect(getOrdinalNumber(101)).toEqual("101st");
25+
test("should return 'th' for the rest numbers", () => {
26+
expect(getOrdinalNumber(10)).toEqual("10th");
27+
expect(getOrdinalNumber(11)).toEqual("11th");
28+
expect(getOrdinalNumber(34)).toEqual("34th");
29+
expect(getOrdinalNumber(134)).toEqual("134th");
9330
});

0 commit comments

Comments
 (0)