@@ -20,13 +20,29 @@ 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-
23+ test ( "should repeat the string count times" , ( ) => {
24+ const str = "hello" ;
25+ const count = 1 ;
26+ const repeatedStr = repeatStr ( str , count ) ;
27+ expect ( repeatedStr ) . toEqual ( "hello" ) ;
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.
28-
33+ test ( "should repeat the string count times" , ( ) => {
34+ const str = "hello" ;
35+ const count = 0 ;
36+ const repeatedStr = repeatStr ( str , count ) ;
37+ expect ( repeatedStr ) . toEqual ( " " ) ;
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+ test ( "should repeat the string count times" , ( ) => {
44+ const str = "hello" ;
45+ const count = - 1 ;
46+ const repeatedStr = repeatStr ( str , count ) ;
47+ expect ( repeatedStr ) . toEqual ( "invalid count" ) ;
48+ } ) ;
0 commit comments