Skip to content

Commit 6a89a27

Browse files
author
cjyuan
committed
Updated 2-practice-tdd
1 parent 7c92cdc commit 6a89a27

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ 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+
// To ensure thorough testing, we need broad scenarios that cover all possible cases.
9+
// Listing individual values, however, can quickly lead to an unmanageable number of test cases.
10+
// Instead of writing tests for individual numbers, consider grouping all possible input values
11+
// into meaningful categories. Then, select representative samples from each category to test.
12+
// This approach improves coverage and makes our tests easier to maintain.
13+
14+
// Case 1: Numbers ending with 1 (but not 11)
15+
// When the number ends with 1, except those ending with 11,
16+
// Then the function should return a string by appending "st" to the number.
17+
test("should append 'st' for numbers ending with 1, except those ending with 11", () => {
1218
expect(getOrdinalNumber(1)).toEqual("1st");
13-
});
19+
expect(getOrdinalNumber(21)).toEqual("21st");
20+
expect(getOrdinalNumber(31)).toEqual("131st");
21+
});

Sprint-3/2-practice-tdd/repeat-str.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ test("should repeat the string count times", () => {
2929
// case: Negative Count:
3030
// Given a target string str and a negative integer count,
3131
// When the repeatStr function is called with these inputs,
32-
// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
32+
// Then it should throw an error, as negative counts are not valid.

0 commit comments

Comments
 (0)