Skip to content

Commit 034d8f8

Browse files
committed
grouping the tests by behaviour
1 parent 4369f3a commit 034d8f8

File tree

1 file changed

+20
-42
lines changed

1 file changed

+20
-42
lines changed

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

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,36 @@ 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"
107

11-
test("should return '1st' for 1", () => {
8+
9+
test("append 'st' to numbers ending in 1, except those ending in 11", () => {
1210
expect(getOrdinalNumber(1)).toEqual("1st");
11+
expect(getOrdinalNumber(221)).toEqual("221st");
12+
expect(getOrdinalNumber(191)).toEqual("191st");
1313
});
14-
// Case 2: Identify the ordinal number for 22
15-
// When the number is 22,
16-
// Then the function should return 22nd"
17-
test("should return '22nd' for 22", () => {
18-
expect(getOrdinalNumber(22)).toEqual("22nd");
14+
test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
15+
expect( getOrdinalNumber(2) ).toEqual("2nd");
16+
expect( getOrdinalNumber(22) ).toEqual("22nd");
17+
expect( getOrdinalNumber(132) ).toEqual("132nd");
1918
});
20-
// Case 3: Identify the ordinal number for 73
21-
// When the number is 73,
22-
// Then the function should return 73rd"
23-
24-
test("should return '73rd' for 73", () => {
25-
expect(getOrdinalNumber(73)).toEqual("73rd");
19+
test("append 'rd' to numbers ending in 3, except those ending in 13", () => {
20+
expect( getOrdinalNumber(3 )).toEqual("3rd");
21+
expect( getOrdinalNumber(33 ) ).toEqual("33rd");
22+
expect( getOrdinalNumber(133) ).toEqual("133rd");
2623
});
2724

28-
// Case 4: Identify the ordinal number for 99
29-
// When the number is 99,
30-
// Then the function should return 99th"
3125

32-
test("should return '99th' for 99", () => {
26+
test("append 'th'to numbers ending in 4-9 or ending with 11,12,13", () => {
3327
expect(getOrdinalNumber(99)).toEqual("99th");
28+
expect(getOrdinalNumber(234)).toEqual("234th");
29+
expect(getOrdinalNumber(11)).toEqual("11th");
30+
expect(getOrdinalNumber(112)).toEqual("112th");
31+
expect(getOrdinalNumber(13)).toEqual("13th");
32+
expect(getOrdinalNumber(313)).toEqual("313th");
3433
});
3534

36-
// Case 5: Identify the ordinal number for number ends with 11,12, or 13
37-
// When the number is 111,
38-
// Then the function should return 111th"
39-
// When the number is 212,
40-
// Then the function should return 212th"
41-
// When the number is 413,
42-
// Then the function should return 413th"
4335

44-
test("should return '111th' for 111", () => {
45-
expect(getOrdinalNumber(111)).toEqual("111th");
46-
});
47-
test("should return '212th' for 212", () => {
48-
expect(getOrdinalNumber(212)).toEqual("212th");
49-
});
50-
test("should return '413th' for 413", () => {
51-
expect(getOrdinalNumber(413)).toEqual("413th");
52-
});
53-
54-
//case 6
55-
// when is the number is 0 or negative number
56-
test("should throw Invalid Input for negative numbers", () => {
36+
test("should throw Invalid Input for negative numbers or 0", () => {
5737
expect(getOrdinalNumber(-5)).toEqual("Invalid Input");
58-
});
59-
test("should throw Invalid Input for 0", () => {
60-
expect(getOrdinalNumber(0)).toEqual("Invalid Input");
38+
expect(getOrdinalNumber(0)).toEqual("Invalid Input");
6139
});

0 commit comments

Comments
 (0)