Skip to content

Commit b0e726e

Browse files
Add empty string tests for repeat-str
1 parent 08c4184 commit b0e726e

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,31 @@ test("should throw an error when count is negative", () => {
4444
const str = "hello";
4545
const count = -1;
4646
expect(() => repeatStr(str, count)).toThrow();
47+
});
48+
49+
test("should return an empty string when repeating an empty string several times", () => {
50+
const str = "";
51+
const count = 3;
52+
const repeatedStr = repeatStr(str, count);
53+
expect(repeatedStr).toEqual("");
54+
});
55+
56+
test("should return an empty string when repeating an empty string once", () => {
57+
const str = "";
58+
const count = 1;
59+
const repeatedStr = repeatStr(str, count);
60+
expect(repeatedStr).toEqual("");
61+
});
62+
63+
test("should return an empty string when repeating an empty string zero times", () => {
64+
const str = "";
65+
const count = 0;
66+
const repeatedStr = repeatStr(str, count);
67+
expect(repeatedStr).toEqual("");
68+
});
69+
70+
test("should throw an error when count is negative, even for an empty string", () => {
71+
const str = "";
72+
const count = -1;
73+
expect(() => repeatStr(str, count)).toThrow();
4774
});

0 commit comments

Comments
 (0)