Skip to content

Commit 8657ab8

Browse files
author
Ogbemi mene
committed
commit test
1 parent 1a46ec8 commit 8657ab8

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+
35+
// Case 1: Multiple repetitions
36+
test("should repeat the string count times", () => {
37+
const str = "hello";
38+
const count = 3;
39+
const repeatedStr = repeatStr(str, count);
40+
expect(repeatedStr).toEqual("hellohellohello");
41+
});
42+
43+
// Case 2: Count of 1
44+
test("should return the original string when count is 1", () => {
45+
expect(repeatStr("hello", 1)).toEqual("hello");
46+
});
47+
48+
// Case 3: Count of 0
49+
test("should return an empty string when count is 0", () => {
50+
expect(repeatStr("hello", 0)).toEqual("");
51+
});
52+
53+
// Case 4: Negative count
54+
test("should throw an error when count is negative", () => {
55+
expect(() => repeatStr("hello", -1)).toThrow(RangeError);
56+
});
57+

0 commit comments

Comments
 (0)