Skip to content

Commit 09b5f7d

Browse files
committed
commit
1 parent 0f15af0 commit 09b5f7d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ test("should repeat the string count times", () => {
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+
test("should repeat the string only once", () => {
24+
expect(repeatStr("nihao",1)).toEqual("nihao");
25+
});
2326

2427
// Case: Handle count of 0:
2528
// Given a target string `str` and a `count` equal to 0,
2629
// When the repeatStr function is called with these inputs,
2730
// Then it should return an empty string.
31+
test("should repeat the string 0", () => {
32+
expect(repeatStr("newyear",0)).toEqual("");
33+
});
2834

2935
// Case: Handle negative count:
3036
// Given a target string `str` and a negative integer `count`,
3137
// When the repeatStr function is called with these inputs,
3238
// Then it should throw an error, as negative counts are not valid.
39+
test("should throw an error when count is negative", () => {
40+
expect(() => repeatStr("celebration", -5))
41+
.toThrow("Count cannot be negative");
42+
});

0 commit comments

Comments
 (0)