Skip to content

Commit 7377a88

Browse files
committed
added more test cases to files as advised by the reviewer
1 parent 3d64708 commit 7377a88

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎practice-tdd/count.test.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ test("should count multiple occurrences of a character", () => {
3737
const count = countChar(str, char);
3838
expect(count).toEqual(0);
3939
});
40+
41+
test("should count multiple occurrences of a character", () => {
42+
const str = "";
43+
const char = "a";
44+
const count = countChar(str, char);
45+
expect(count).toEqual(0);
46+
});

‎practice-tdd/get-ordinal-number.test.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ test("should append 'rd' for numbers ending with 3", () => {
3333

3434
test("should append 'th' for numbers ending with 4, except those ending with 0", () => {
3535
expect(getOrdinalNumber(4)).toEqual("4th");
36+
expect(getOrdinalNumber(11)).toEqual("11th");
37+
expect(getOrdinalNumber(12)).toEqual("12th");
38+
expect(getOrdinalNumber(13)).toEqual("13th");
39+
expect(getOrdinalNumber(20)).toEqual("20th");
40+
expect(getOrdinalNumber(111)).toEqual("111th");
41+
expect(getOrdinalNumber(113)).toEqual("113th");
3642
expect(getOrdinalNumber(144)).toEqual("144th");
3743
expect(getOrdinalNumber(40)).toEqual("40th");
3844
});

‎practice-tdd/repeat-str.test.js‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ test("should repeat the string count times", () => {
2222
// Then it should return the original `str` without repetition.
2323

2424
test("should repeat the string count times", () => {
25-
const str = "hello";
25+
const str = "Morning";
2626
const count = 1;
2727
const repeatedStr = repeatStr(str, count);
28-
expect(repeatedStr).toEqual("hello");
28+
expect(repeatedStr).toEqual("Morning");
2929
});
3030

3131
// Case: Handle count of 0:
@@ -40,6 +40,13 @@ test("should repeat the string count times", () => {
4040
expect(repeatedStr).toEqual("");
4141
});
4242

43+
test("should repeat the string count times", () => {
44+
const str = "Hiya!";
45+
const count = 0;
46+
const repeatedStr = repeatStr(str, count);
47+
expect(repeatedStr).toEqual("");
48+
});
49+
4350
// Case: Handle negative count:
4451
// Given a target string `str` and a negative integer `count`,
4552
// When the repeatStr function is called with these inputs,
@@ -50,3 +57,10 @@ test("should throw an error, as negative counts are not valid", () => {
5057
const count = -1;
5158
expect(() => repeatStr(str, count)).toThrow("negative counts are not valid");
5259
});
60+
61+
test("should repeat the string count times", () => {
62+
const str = "";
63+
const count = 4;
64+
const repeatedStr = repeatStr(str, count);
65+
expect(repeatedStr).toEqual("");
66+
});

0 commit comments

Comments
 (0)