Skip to content

Commit 09d914f

Browse files
repeat-str.test.js
1 parent 53b6621 commit 09d914f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,28 @@ test("should repeat the string count times", () => {
3030
// Given a target string `str` and a negative integer `count`,
3131
// When the repeatStr function is called with these inputs,
3232
// Then it should throw an error, as negative counts are not valid.
33+
34+
test("should return the original string when count is 1", () => {
35+
const str = "hello";
36+
const count = 1;
37+
38+
const repeatedStr = repeatStr(str, count);
39+
40+
expect(repeatedStr).toEqual("hello");
41+
});
42+
43+
test("should return an empty string when count is 0", () => {
44+
const str = "hello";
45+
const count = 0;
46+
47+
const repeatedStr = repeatStr(str, count);
48+
49+
expect(repeatedStr).toEqual("");
50+
});
51+
52+
test("should throw an error when count is negative", () => {
53+
const str = "hello";
54+
const count = -1;
55+
56+
expect(() => repeatStr(str, count)).toThrow();
57+
});

0 commit comments

Comments
 (0)