@@ -10,23 +10,39 @@ const repeatStr = require("./repeat-str");
1010// Then it should return a string that contains the original `str` repeated `count` times.
1111
1212test("should repeat the string count times", () => {
13- const str = "hello";
14- const count = 3;
15- const repeatedStr = repeatStr(str, count );
13+ let word = "hello";
14+ let times = 3;
15+ const repeatedStr = repeatStr(word, times );
1616 expect(repeatedStr).toEqual("hellohellohello");
1717});
1818
1919// Case: handle count of 1:
2020// Given a target string `str` and a `count` equal to 1,
2121// When the repeatStr function is called with these inputs,
2222// Then it should return the original `str` without repetition.
23-
23+ test("should repeat the string count times", () => {
24+ let word = "code your future";
25+ let times = 1;
26+ const repeatedStr = repeatStr(word, times);
27+ expect(repeatedStr).toEqual("code your future");
28+ });
2429// Case: Handle count of 0:
2530// Given a target string `str` and a `count` equal to 0,
2631// When the repeatStr function is called with these inputs,
2732// Then it should return an empty string.
28-
33+ test("should repeat the string is empty ", () => {
34+ let word = "hello";
35+ let times = 0;
36+ const repeatedStr = repeatStr(word, times);
37+ expect(repeatedStr).toBe("");
38+ });
2939// Case: Handle negative count:
3040// Given a target string `str` and a negative integer `count`,
3141// When the repeatStr function is called with these inputs,
3242// Then it should throw an error, as negative counts are not valid.
43+ test("should repeat the string return negative number not allowed ", () => {
44+ let word = "hello";
45+ let times = -3;
46+ const repeatedStr = repeatStr(word, times);
47+ expect(repeatedStr).toBe("Error:negative number not allowed");
48+ });
0 commit comments