@@ -20,13 +20,28 @@ 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+ test ( "should repeat string count times" , ( ) => {
24+ const str = "bye" ;
25+ const count = 1 ;
26+ const repeatedStr = repeatStr ( str , count ) ;
27+ expect ( repeatedStr ) . toEqual ( "bye" ) ;
28+ } ) ;
2329
2430// Case: Handle count of 0:
2531// Given a target string `str` and a `count` equal to 0,
2632// When the repeatStr function is called with these inputs,
2733// Then it should return an empty string.
34+ test ( "should repeat string count times" , ( ) => {
35+ const str = "no" ;
36+ const count = 0 ;
37+ const repeatedStr = repeatStr ( str , count ) ;
38+ expect ( repeatedStr ) . toEqual ( "" ) ;
39+ } ) ;
2840
2941// Case: Handle negative count:
3042// Given a target string `str` and a negative integer `count`,
3143// When the repeatStr function is called with these inputs,
3244// Then it should throw an error, as negative counts are not valid.
45+ test ( "should throw an error for negative numbers" , ( ) => {
46+ expect ( ( ) => repeatStr ( "str" , - 2 ) ) . toThrow ( "negative counts are not valid" ) ;
47+ } ) ;
0 commit comments