Skip to content

Commit 5ee3f6b

Browse files
author
Payman IB
committed
Update negative count test to ensure it throws an error instead of returning a message
1 parent bbc996c commit 5ee3f6b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ test("should return an empty string when count is 0", () => {
3636
// Given a target string str and a negative integer count,
3737
// When the repeat function is called with these inputs,
3838
// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
39-
test("should return a message for negative count", () => {
39+
test("should throw an error for negative count", () => {
4040
const str = "error";
4141
const count = -2;
42-
const repeatedStr = repeat(str, count);
43-
expect(repeatedStr).toEqual("Count must be a non-negative integer");
42+
43+
expect(() => repeat(str, count)).toThrow("Count must be a non-negative integer");
4444
});

0 commit comments

Comments
 (0)