File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,12 +21,27 @@ test("should repeat the string count times", () => {
2121// When the repeatStr function is called with these inputs,
2222// Then it should return the original `str` without repetition.
2323
24+ test ( "should return the original string when count is 1" , ( ) => {
25+ expect ( repeatStr ( "hello" , 1 ) ) . toEqual ( "hello" ) ;
26+ } ) ;
27+
28+
2429// Case: Handle count of 0:
2530// Given a target string `str` and a `count` equal to 0,
2631// When the repeatStr function is called with these inputs,
2732// Then it should return an empty string.
2833
34+ test ( "should return an empty string when count is 0" , ( ) => {
35+ expect ( repeatStr ( "hello" , 0 ) ) . toEqual ( "" ) ;
36+ } ) ;
37+
38+
2939// Case: Handle negative count:
3040// Given a target string `str` and a negative integer `count`,
3141// When the repeatStr function is called with these inputs,
3242// Then it should throw an error, as negative counts are not valid.
43+
44+
45+ test ( "should throw an error when count is negative" , ( ) => {
46+ expect ( ( ) => repeatStr ( "hello" , - 1 ) ) . toThrow ( "Count cannot be negative" ) ;
47+ } ) ;
You can’t perform that action at this time.
0 commit comments