Skip to content

Commit 8b6b488

Browse files
wrote a test case to throw and error for negtive count
1 parent 8767246 commit 8b6b488

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ test("should return an empty string when count is 0", () => {
4141
expect(repeatedStr).toEqual("");
4242
});
4343

44-
// Case: Handle negative count:
44+
// Case: Handle negative count:
4545
// Given a target string `str` and a negative integer `count`,
4646
// When the repeatStr function is called with these inputs,
4747
// Then it should throw an error, as negative counts are not valid.
48+
test("should throw an error when count is negative", () => {
49+
const str = "hello";
50+
const count = -1;
51+
expect(() => repeatStr(str, count)).toThrow();
52+
});

0 commit comments

Comments
 (0)