Skip to content

Commit 9f7796a

Browse files
committed
restored all coments as advised
1 parent 08dccc1 commit 9f7796a

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// Implement a function repeatStr
22
import { repeatStr } from "./repeat-str.js";
3+
// Given a target string `str` and a positive integer `count`,
4+
// When the repeatStr function is called with these inputs,
5+
// Then it should:
6+
7+
// Case: handle multiple repetitions:
8+
// Given a target string `str` and a positive integer `count` greater than 1,
9+
// When the repeatStr function is called with these inputs,
10+
// Then it should return a string that contains the original `str` repeated `count` times.
11+
312
// Case: handle count of 1, 2, 3, 4:
413
test("should repeat the string 1 times", () => {
514
const str = "hello";
@@ -32,14 +41,17 @@ test("should repeat the string 0 times", () => {
3241
const repeatedStr = repeatStr(str, count);
3342
expect(repeatedStr).toEqual("");
3443
});
35-
//case: Handle decimal count
44+
//case: Handle decimal count:
3645
test("should repeat the stringthe whole number in the count times", () => {
3746
const str = "hello";
3847
const count = 2.5;
3948
const repeatedStr = repeatStr(str, count);
4049
expect(repeatedStr).toEqual("hellohello");
4150
});
4251
// Case: Handle negative count:
52+
// Given a target string `str` and a negative integer `count`,
53+
// When the repeatStr function is called with these inputs,
54+
// Then it should throw an error, as negative counts are not valid
4355
test("should throw an error when -1 count is given", () => {
4456
expect(() => repeatStr("hello", -1)).toThrow("Negative counts are not valid");
4557
});

0 commit comments

Comments
 (0)